All,
I am currently working on setting up a ListBox to improve the clarity of my application. Basically, it's pretty easy to find an βhowβ for this purpose, leading to my current result below.

I am happy with the display, but ... I came across strange behavior with the mouse wheel. I tried to find information on this issue, and I found this article:
http://aviationxchange.net/wikis/winforms/net-color-listbox.aspx
which indicate that the problem with the mouse wheel is not the only one (simple copy / paste by reference)
- The horizontal scrollbar has disappeared. Only fixed-length lines shorter than the width of the control can be displayed. What if the size of the control has changed?
- If you tried to use the mouse wheel, you might notice that the selected item moves up and down as you move the scroll wheel.
- Overridden methods OnPaint () OnPaintBackGround () do not work at all. They just are not tied to events. The background is painted only through Windows messages.
This gives some tips for fixing these issues, but I feel pretty disappointed to implement all of these βworkaroundsβ to display my own list. Did I miss something? is there any winform control that allows me the same settings, but in a cleaner / more elegant way? I could not find more information: /
The corresponding part of the user part of the drawing is added below, but I'm not sure that the display problem is really based on the implementation of the overridden method, more on the control itself.
public RecordListBox(): base() { mListBox = this; mListBox.DrawItem += new DrawItemEventHandler(mListBox_DrawItem); mListBox.MeasureItem += new MeasureItemEventHandler(mListBox_MeasureItem); this.DrawMode = DrawMode.OwnerDrawFixed; } public void mListBox_DrawItem(object sender, DrawItemEventArgs e) { if (this.DesignMode) return; e.DrawBackground(); e.DrawFocusRectangle();
With respect,
source share