How to change color of an individual item in checkedlistbox

paldebu78

Member
Joined
Sep 14, 2006
Messages
5
Programming Experience
Beginner
I am working on visual studio 2005. I have put a checkedlistbox on a windows form (in vb.net) and adding items in the checkedlistbox from database. Is there any way I can set the color of some of the items in the checkedlistbox red and others black based on some condition? If there is any way how can I do that? Please help
 
I would strongly suggest using a datagrid rather then a checked list box. It will save you many future head aches. The way to change the background color conditionally is to create a new control and inherit the datagridboolcolumn. and override the "Paint". In the code for your override paint sub Do all your conditional formating then just call mybase.paint, and substitute the background, or foreground color that you chose based on your conditional formating. If you have any issues let me know, and I can give you some working code on this. Check out syncfusion conditional format datagrid, and you should be led to a article that explains this step by step.
 
Please post in the most appropriate forum for the topic. The VS.NET General forum is for general questions regarding the IDE. This is not an IDE-related question.

Moved.
 
CheckedListBox does not support OwnerDraw mode, ListView control can do that (Listview.DrawItem documentation has code sample). Also DataGridView control can be used easier.
 
Back
Top