Bagikan melalui


SelectedGridItemChangedEventArgs.OldSelection Properti

Definisi

Mendapatkan yang sebelumnya dipilih GridItem.

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

Nilai Properti

Yang lama GridItem. Ini bisa menjadi null.

Contoh

Contoh kode berikut menunjukkan penggunaan anggota ini. Dalam contoh, penanganan aktivitas melaporkan kemunculan PropertyGrid.SelectedGridItemChanged peristiwa. Laporan ini membantu Anda mempelajari kapan peristiwa terjadi dan dapat membantu Anda dalam penelusuran kesalahan. Untuk melaporkan beberapa peristiwa atau peristiwa yang sering terjadi, pertimbangkan untuk mengganti MessageBox.Show dengan Console.WriteLine atau menambahkan pesan ke multibaris TextBox.

Untuk menjalankan kode contoh, tempelkan ke dalam proyek yang berisi instans jenis PropertyGrid bernama PropertyGrid1. Kemudian pastikan bahwa penanganan aktivitas dikaitkan dengan peristiwa.PropertyGrid.SelectedGridItemChanged

private void PropertyGrid1_SelectedGridItemChanged(Object sender, SelectedGridItemChangedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "NewSelection", e.NewSelection );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "OldSelection", e.OldSelection );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "SelectedGridItemChanged Event" );
}
Private Sub PropertyGrid1_SelectedGridItemChanged(sender as Object, e as SelectedGridItemChangedEventArgs) _ 
     Handles PropertyGrid1.SelectedGridItemChanged

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "NewSelection", e.NewSelection)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "OldSelection", e.OldSelection)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"SelectedGridItemChanged Event")

End Sub

Berlaku untuk