I have created a custom ListBox in c#. I have drawn text and image on my custom ListBox using DrawItemEventArgs. I want to fill a color in my rectangle(Item of ListBox) when mouse is hovered over it. Is there a way for it using DrawItemEventArgs or otherwise. Please help. Thanks in advance.
Asked
Active
Viewed 301 times
1 Answers
0
You should check on which item the mouse is. ListBox has a method to do such a check: IndexFromPoint https://msdn.microsoft.com/en-us/library/kfw3x8dc%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
Now, when you have item index, you can get its rectangle using other method: GetItemRectangle https://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.getitemrectangle(v=vs.110).aspx

Adam Jachocki
- 1,897
- 1
- 12
- 28