Occurs when an owner-drawn ListBox is created and the sizes of the list items are determined.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
You can create an event handler for this event to specify the size an item will be made before it is drawn in the DrawItem event. The event is only raised when the DrawMode property is set to OwnerDrawVariable.
The maximum valid height of a ListBox item is 255 pixels. Setting the ItemHeight property of the MeasureItemEventArgs to a value greater than 255 when handling this event may yield unexpected results.
For more information about handling events, see Handling and Raising Events.
The following code example demonstrates an owner-drawn ListBox by setting the DrawMode property to OwnerDrawVariable and handling the DrawItem and events. It also demonstrates setting the BorderStyle and ScrollAlwaysVisible properties and using the AddRange method.
To run this example, paste it in an empty form that imports the System.Drawing namespace and the System.Windows.Forms namespace. Call InitializeOwnerDrawnListBox from the form's constructor or Load event-handling method.
Available since 1.1