DrawListViewSubItemEventArgs.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 value indicating whether the ListViewItem.ListViewSubItem should be drawn by the operating system instead of owner-drawn.

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 subitem should be drawn by the operating system; otherwise, false. The default is false.

Use this property when handling the ListView.DrawSubItem event for subitems that you do not want to customize. If you set this property to true, the subitem will be drawn normally using the current values of the ListViewItem.ListViewSubItem.BackColor, ListViewItem.ListViewSubItem.ForeColor, and ListViewItem.ListViewSubItem.Font properties

System_CAPS_noteNote

The UseItemStyleForSubItems property of the parent ListViewItem must be set to false to prevent the ListViewItem.BackColor value of the parent item from overriding the subitem value.

The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the ListView.DrawSubItem 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.DrawSubItem event.

private void ListView1_DrawSubItem(Object sender, DrawListViewSubItemEventArgs 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}", "Bounds", e.Bounds );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Item", e.Item );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "SubItem", e.SubItem );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ItemIndex", e.ItemIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Header", e.Header );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ItemState", e.ItemState );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "DrawSubItem Event" );
}

.NET Framework
Available since 2.0
Return to top
Show: