Occurs when a visual aspect of an owner-drawn ListBox changes.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
This event is used by an owner-drawn ListBox. The event is only raised when the DrawMode property is set to DrawMode.OwnerDrawFixed or DrawMode.OwnerDrawVariable. You can use this event to perform the tasks needed to draw items in the ListBox. If you have a variable-sized item (when the DrawMode property is set to DrawMode.OwnerDrawVariable), before drawing an item, the MeasureItem event is raised. You can create an event handler for the MeasureItem event to specify the size for the item that you are going to draw in your event handler for the event.
For more information about handling events, see Handling and Raising Events.
The following code example demonstrates how to create owner-drawn ListBox items. The code uses the DrawMode property to specify that the items drawn are fixed sized and the event to perform the drawing of each item into the ListBox. The example code uses the properties and methods of the DrawItemEventArgs class passed as a parameter to the event handler to draw the items. This example requires that a ListBox control called listBox1 has been added to a form and that the event is handled by the event handler defined in the example code. The example also requires that items have been added to the ListBox with the text of "Apple", "Orange", and "Plum" in that order.
Available since 1.1