DrawListViewSubItemEventArgs.Item Egenskap

Definition

Hämtar överordnad ListViewItem till att ListViewItem.ListViewSubItem rita.

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

Egenskapsvärde

En ListViewItem som representerar överordnad för att ListViewItem.ListViewSubItem rita.

Exempel

Följande kodexempel visar hur den här medlemmen används. I exemplet rapporterar en händelsehanterare om händelsens ListView.DrawSubItem förekomst. Den här rapporten hjälper dig att lära dig när händelsen inträffar och kan hjälpa dig att felsöka.

Om du vill köra exempelkoden klistrar du in den i ett projekt som innehåller en instans av typen ListView med namnet ListView1. Kontrollera sedan att händelsehanteraren är associerad med ListView.DrawSubItem händelsen.

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

Kommentarer

Använd den här egenskapen för att komma åt den ListViewItem överordnade ListViewItem.ListViewSubItem för att rita. Detta är användbart när egenskapen ItemState inte ger tillräcklig information för att uppfylla dina behov. Egenskapen ItemState innehåller endast grundläggande tillståndsinformation som du kan använda, till exempel för att avgöra om det överordnade objektet är markerat, markerat eller fokuserat. Med Item egenskapen kan du å andra sidan komma åt alla medlemmar i den överordnade ListViewItem.

Använd egenskapen för ListViewItem.ListViewSubItem att komma åt den SubItem som ritas.

Gäller för

Se även