Edit

Share via


DrawListViewSubItemEventArgs.Item Property

Definition

Gets the parent ListViewItem of the ListViewItem.ListViewSubItem to draw.

public:
 property System::Windows::Forms::ListViewItem ^ Item { System::Windows::Forms::ListViewItem ^ get(); };
public System.Windows.Forms.ListViewItem Item { get; }
public System.Windows.Forms.ListViewItem? Item { get; }
member this.Item : System.Windows.Forms.ListViewItem
Public ReadOnly Property Item As ListViewItem

Property Value

A ListViewItem that represents the parent of the ListViewItem.ListViewSubItem to draw.

Examples

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" );
}
Private Sub ListView1_DrawSubItem(sender as Object, e as DrawListViewSubItemEventArgs) _ 
     Handles ListView1.DrawSubItem

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "DrawDefault", e.DrawDefault)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Graphics", e.Graphics)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Bounds", e.Bounds)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Item", e.Item)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "SubItem", e.SubItem)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ItemIndex", e.ItemIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Header", e.Header)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ItemState", e.ItemState)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"DrawSubItem Event")

End Sub

Remarks

Use this property to access the ListViewItem parent of the ListViewItem.ListViewSubItem to draw. This is useful when the ItemState property does not provide adequate information to meet your needs. The ItemState property provides only basic state information that you can use, for example, to determine whether the parent item is selected, checked, or focused. The Item property, on the other hand, allows you to access all members of the parent ListViewItem.

To access the ListViewItem.ListViewSubItem being drawn, use the SubItem property.

Applies to

See also