DrawListViewItemEventArgs.DrawDefault Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets a property indicating whether the ListView control will use the default drawing for the ListViewItem.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public bool DrawDefault { get; set; }

Property Value

Type: System.Boolean

true if the system draws the item; false if the event handler draws the item. The default value is false.

Set this property to true when the item does not require custom drawing. This is useful when you need to customize only certain items within the control, such as selected items.

The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the ListView.DrawItem event. This report helps you to learn when the event occurs and can assist you in debugging.

To run the example code, paste it into a project that contains an instance of type ListView named ListView1. Then ensure that the event handler is associated with the ListView.DrawItem event.

private void ListView1_DrawItem(Object sender, DrawListViewItemEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "DrawDefault", e.DrawDefault );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Graphics", e.Graphics );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Item", e.Item );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Bounds", e.Bounds );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ItemIndex", e.ItemIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "State", e.State );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "DrawItem Event" );
}

.NET Framework
Available since 2.0
Return to top
Show: