DataGridView.ColumnAdded Zdarzenie

Definicja

Występuje po dodaniu kolumny do kontrolki.

public:
 event System::Windows::Forms::DataGridViewColumnEventHandler ^ ColumnAdded;
public event System.Windows.Forms.DataGridViewColumnEventHandler ColumnAdded;
public event System.Windows.Forms.DataGridViewColumnEventHandler? ColumnAdded;
member this.ColumnAdded : System.Windows.Forms.DataGridViewColumnEventHandler 
Public Custom Event ColumnAdded As DataGridViewColumnEventHandler 

Typ zdarzenia

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 ColumnAdded . 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 DataGridView o nazwie DataGridView1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem ColumnAdded .

private void DataGridView1_ColumnAdded(Object sender, DataGridViewColumnEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Column", e.Column );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "ColumnAdded Event" );
}
Private Sub DataGridView1_ColumnAdded(sender as Object, e as DataGridViewColumnEventArgs) _ 
     Handles DataGridView1.ColumnAdded

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

End Sub

Uwagi

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Dotyczy

Zobacz też