changing colors for listview rows
-
Can we change the background color of the listview such that we can have row 1 which can have background color as red and row2 should have background color as blue ? Thanks
Try the following , when you are adding a item to your list view check for alternate row to apply different color. Say if current row is odd row then write
ListView1.Items(itemindex).BackColor = (New System.Drawing.Color).Aquamarine
and if it is even thenListView1.Items(itemindex).BackColor = (New System.Drawing.Color).Bisque
Please note that this code colors background of all columns but if the last column width dosen't fills the list view then the list view background appears. So make sure that you columns fits the listview width. Kumar Saurabh -
Can we change the background color of the listview such that we can have row 1 which can have background color as red and row2 should have background color as blue ? Thanks
I never coding in for this purpose, but I just have some concept from other developer on the internet. Example that you loop to call record from the database and display on the list view. 1. Loop one by one of your record to and put it in the listview row by row. 2. May be use MOD function to check for a remain value of listview index number. (if 2/2 remain 0, if 3/2 remain 1). 3. Base on the remain (only 1 and 0) they can set the background of each row in the listview at the time of loop process. Try to use google to search for this case and wish you good luck.
A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office
-
Try the following , when you are adding a item to your list view check for alternate row to apply different color. Say if current row is odd row then write
ListView1.Items(itemindex).BackColor = (New System.Drawing.Color).Aquamarine
and if it is even thenListView1.Items(itemindex).BackColor = (New System.Drawing.Color).Bisque
Please note that this code colors background of all columns but if the last column width dosen't fills the list view then the list view background appears. So make sure that you columns fits the listview width. Kumar SaurabhKumar saurabh wrote: Say if current row is odd row then write ListView1.Items(itemindex).BackColor = (New System.Drawing.Color).Aquamarine and if it is even then ListView1.Items(itemindex).BackColor = (New System.Drawing.Color).Bisque How do you determine which row is ODD or EVEN?
A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office