DataGridView.ColumnDefaultCellStyleChanged イベント

定義

列の DefaultCellStyle プロパティの値が変更された場合に発生します。

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

イベントの種類

次のコード例では、このメンバーの使用方法を示します。 この例では、イベント ハンドラーがイベントの ColumnDefaultCellStyleChanged 発生を報告します。 このレポートは、イベントが発生したタイミングを確認するのに役立ち、デバッグに役立ちます。 複数のイベントまたは頻繁に発生するイベントを報告するには、 を Console.WriteLine に置き換えるかMessageBox.Show、複数行TextBoxにメッセージを追加することを検討してください。

コード例を実行するには、 という名前DataGridView1の型DataGridViewのインスタンスを含むプロジェクトに貼り付けます。 次に、イベント ハンドラーがイベントに関連付けられていることを確認します ColumnDefaultCellStyleChanged

private void DataGridView1_ColumnDefaultCellStyleChanged(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(), "ColumnDefaultCellStyleChanged Event" );
}
Private Sub DataGridView1_ColumnDefaultCellStyleChanged(sender as Object, e as DataGridViewColumnEventArgs) _ 
     Handles DataGridView1.ColumnDefaultCellStyleChanged

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

End Sub

注釈

このイベントは、列の DataGridViewCellStyle プロパティによって DefaultCellStyle 返される のプロパティが新しい値に設定されている場合、または列の DefaultCellStyle プロパティが、前のセル スタイル オブジェクトとは異なるプロパティ値が少なくとも 1 つの新しい DataGridViewCellStyle に設定されている場合に発生します。

イベントを処理する方法の詳細については、次を参照してください。処理とイベントの発生します。

適用対象

こちらもご覧ください