ColumnReorderedEventArgs.OldDisplayIndex Właściwość

Definicja

Pobiera poprzednią pozycję wyświetlania elementu ColumnHeader.

public:
 property int OldDisplayIndex { int get(); };
public int OldDisplayIndex { get; }
member this.OldDisplayIndex : int
Public ReadOnly Property OldDisplayIndex As Integer

Wartość właściwości

Poprzednia pozycja wyświetlania elementu ColumnHeader

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.ColumnReordered . 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.ColumnReordered .

private void ListView1_ColumnReordered(Object sender, ColumnReorderedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "OldDisplayIndex", e.OldDisplayIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "NewDisplayIndex", e.NewDisplayIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Header", e.Header );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "ColumnReordered Event" );
}
Private Sub ListView1_ColumnReordered(sender as Object, e as ColumnReorderedEventArgs) _ 
     Handles ListView1.ColumnReordered

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "OldDisplayIndex", e.OldDisplayIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "NewDisplayIndex", e.NewDisplayIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Header", e.Header)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"ColumnReordered Event")

End Sub

Uwagi

Zdarzenie ColumnReordered można anulować, ustawiając Cancel właściwość na true. Jeśli jednak zdarzenie zostanie anulowane, wartość NewDisplayIndex nie zostanie zmieniona OldDisplayIndex .

Dotyczy