LabelEditEventArgs.Label Właściwość

Definicja

Pobiera nowy tekst przypisany do etykiety elementu ListViewItem.

public:
 property System::String ^ Label { System::String ^ get(); };
public string Label { get; }
public string? Label { get; }
member this.Label : string
Public ReadOnly Property Label As String

Wartość właściwości

Nowy tekst, który ma być skojarzony z tekstem ListViewItem lub null jest niezmieniony.

Przykłady

Poniższy przykład kodu przedstawia użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie zdarzenia ListView.AfterLabelEdit . Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub zdarzeń, które występują często, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączeniem go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu ListView o nazwie ListView1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem ListView.AfterLabelEdit .

private void ListView1_AfterLabelEdit(Object sender, LabelEditEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Label", e.Label );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Item", e.Item );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "CancelEdit", e.CancelEdit );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "AfterLabelEdit Event" );
}
Private Sub ListView1_AfterLabelEdit(sender as Object, e as LabelEditEventArgs) _ 
     Handles ListView1.AfterLabelEdit

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Label", e.Label)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Item", e.Item)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "CancelEdit", e.CancelEdit)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"AfterLabelEdit Event")

End Sub

Dotyczy