It seems to use default color from Windows settings which is blue by default. Let's say I want to change it to red permanently. I'm using Winforms.
Thanks in advance.
It seems to use default color from Windows settings which is blue by default. Let's say I want to change it to red permanently. I'm using Winforms.
Thanks in advance.
Hopefully this will help someone in the future as the above code helped me but not 100%
I still had the following problems:
- when i selected another index, the newly selected index would also highlight red.
- when i changed the font size of the listbox, the highlighted area would be to small.
Below fixes that problem
I also referenced the MSDN website.
I have the same problem.
Unfortunately my datasource is a List of Entity Class. So I have the same code with the accepted answer above but with minor modification to select the exact property on my Class that I need on DrawString for my ListBox:
The below code does exactly what you are saying:
In the InitializeComponent method:
And the event handlers:
Code is taken from:
http://www.weask.us/entry/change-listbox-rsquo-selected-item-backcolor-net
You must override the
Drawitem
event and set theDrawMode
property toDrawMode.OwnerDrawFixed
check this sample