Not much else to say, on the code, look directly
First set this line, or the Properties window settings, so that you can start manual drawing, parameters have three
Normal: Auto Draw
OwnerDrawFixed: Draw manually but with the same spacing
OwnerDrawVariable: Manual drawing with different spacing
Listbox1.drawmode= drawmode.ownerdrawfixed
Then write the drawing code in the DrawItem event
E.graphics.fillrectangle (new SolidBrush (color), e.bounds); // Draw Background New SolidBrush (E.forecolor), e.bounds); // Draw Text E.drawfocusrectangle (); // draw a focus frame
There is no effect of drawing the focus frame, it seems necessary that the ComboBox is only valid when Dropdownstyle=dropdownlist
If set to OwnerDrawVariable, you also need to set the MeasureItem event to return the height of each row (E. Itemwidth = 260).
If the dashed line is drawn, the pen needs to set DashStyle or DashPattern (high priority).
C#listbox to redraw the item, including the color