ListControlConvertEventArgs.ListItem Właściwość

Definicja

Pobiera element źródła danych.

public:
 property System::Object ^ ListItem { System::Object ^ get(); };
public object ListItem { get; }
public object? ListItem { get; }
member this.ListItem : obj
Public ReadOnly Property ListItem As Object

Wartość właściwości

Element Object reprezentujący element w źródle danych.

Przykłady

W poniższym przykładzie kodu pokazano użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie ListControl.Format zdarzenia. Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie, i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub często występujących zdarzeń, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączenie go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu dziedziczonego z ListControlelementu , takiego jak ComboBox lub ListBox. Następnie nadaj wystąpieniu ListControl1 nazwę i upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem ListControl.Format .

private void ListControl1_Format(Object sender, ListControlConvertEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ListItem", e.ListItem );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Value", e.Value );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "DesiredType", e.DesiredType );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Format Event" );
}
Private Sub ListControl1_Format(sender as Object, e as ListControlConvertEventArgs) _ 
     Handles ListControl1.Format

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "ListItem", e.ListItem)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Value", e.Value)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "DesiredType", e.DesiredType)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Format Event")

End Sub

Dotyczy