listbox alternating backcolor

tcl4p

Well-known member
Joined
Feb 29, 2008
Messages
48
Programming Experience
1-3
Does anyone have vb.net code to set the backcolor on a list box on alternating rows? i.e. white one row, cyan the next.

Thanks,
Tom
 
This has been asked many times on many forums, the answer is not an easy one, would you consider a listview in 'list' view which looks the same and would be soooo much easier? This I can help you with.
 
Newguy,
Thanks, I did do a search, but didn't find much. If nothing else comes back I'll switch to another control, where its available.

Tom
 
For ListBox you have to set DrawMode to OwnerDrawFixed and handle the DrawItem event, see DrawMode/DrawItem in help for code example.
ListView is much easier as you can just set BackColor for each ListViewItem (calculate index Mod 2 to alternate).
 
Back
Top