SelectedGridItemChangedEventArgs.NewSelection Proprietà

Definizione

Ottiene l'oggetto appena selezionato GridItem.

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

Valore della proprietà

GridItemNuovo oggetto .

Esempio

Nell'esempio di codice seguente viene illustrato l'uso di questo membro. Nell'esempio un gestore eventi segnala l'occorrenza dell'evento PropertyGrid.SelectedGridItemChanged . Questo report consente di apprendere quando si verifica l'evento e di facilitare il debug. Per segnalare più eventi o eventi che si verificano frequentemente, è consigliabile sostituire MessageBox.Show con Console.WriteLine o accodare il messaggio a un oggetto multilinea TextBox.

Per eseguire il codice di esempio, incollarlo in un progetto contenente un'istanza di tipo PropertyGrid denominata PropertyGrid1. Assicurarsi quindi che il gestore eventi sia associato all'evento 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

Si applica a