DataGridView.CommitEdit メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridView.CommitEdit メソッドの意味・解説 

DataGridView.CommitEdit メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

編集モード終了せずに、現在のセル変更データ キャッシュコミットます。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Function CommitEdit ( _
    context As DataGridViewDataErrorContexts _
) As Boolean
Dim instance As DataGridView
Dim context As DataGridViewDataErrorContexts
Dim returnValue As Boolean

returnValue = instance.CommitEdit(context)
public bool CommitEdit (
    DataGridViewDataErrorContexts context
)
public:
bool CommitEdit (
    DataGridViewDataErrorContexts context
)
public boolean CommitEdit (
    DataGridViewDataErrorContexts context
)
public function CommitEdit (
    context : DataGridViewDataErrorContexts
) : boolean

パラメータ

context

エラー発生したコンテキスト指定する DataGridViewDataErrorContexts 値のビットごとの組み合わせ

戻り値
変更コミットされた場合trueそれ以外場合false

例外例外
例外種類条件

Exception

セルの値をコミットできません。DataError イベントハンドラ存在しないか、ハンドラによって DataGridViewDataErrorEventArgs.ThrowException プロパティtrue設定されました。

解説解説
使用例使用例

CurrentCellDirtyStateChangedイベント ハンドラ内の CommitEdit メソッド呼び出してCellValueChanged イベント発生させるコード例次に示します次のコード例は、「方法 : Windows フォーム DataGridView コントロールボタン列にあるボタン無効にする」で示されている例の一部です。

' This event handler manually raises the CellValueChanged event
' by calling the CommitEdit method.
Sub dataGridView1_CurrentCellDirtyStateChanged( _
    ByVal sender As Object,
 ByVal e As EventArgs) _
    Handles dataGridView1.CurrentCellDirtyStateChanged

    If dataGridView1.IsCurrentCellDirty Then
        dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
    End If
End Sub

' If a check box cell is clicked, this event handler disables  
' or enables the button in the same row as the clicked cell.
Public Sub dataGridView1_CellValueChanged(ByVal
 sender As Object, _
    ByVal e As DataGridViewCellEventArgs) _
    Handles dataGridView1.CellValueChanged

    If dataGridView1.Columns(e.ColumnIndex).Name = "CheckBoxes"
 Then
        Dim buttonCell As DataGridViewDisableButtonCell
 = _
            CType(dataGridView1.Rows(e.RowIndex).Cells("Buttons"),
 _
            DataGridViewDisableButtonCell)

        Dim checkCell As DataGridViewCheckBoxCell
 = _
            CType(dataGridView1.Rows(e.RowIndex).Cells("CheckBoxes"),
 _
            DataGridViewCheckBoxCell)
        buttonCell.Enabled = Not CType(checkCell.Value, [Boolean])

        dataGridView1.Invalidate()
    End If
End Sub
// This event handler manually raises the CellValueChanged event
// by calling the CommitEdit method.
void dataGridView1_CurrentCellDirtyStateChanged(object sender
,
    EventArgs e)
{
    if (dataGridView1.IsCurrentCellDirty)
    {
        dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
    }
}

// If a check box cell is clicked, this event handler disables  
// or enables the button in the same row as the clicked cell.
public void dataGridView1_CellValueChanged(object
 sender,
    DataGridViewCellEventArgs e)
{
    if (dataGridView1.Columns[e.ColumnIndex].Name == "CheckBoxes")
    {
        DataGridViewDisableButtonCell buttonCell =
            (DataGridViewDisableButtonCell)dataGridView1.
            Rows[e.RowIndex].Cells["Buttons"];

        DataGridViewCheckBoxCell checkCell =
            (DataGridViewCheckBoxCell)dataGridView1.
            Rows[e.RowIndex].Cells["CheckBoxes"];
        buttonCell.Enabled = !(Boolean)checkCell.Value;

        dataGridView1.Invalidate();
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridView クラス
DataGridView メンバ
System.Windows.Forms 名前空間
DataGridViewDataErrorContexts
CellParsing
DataError
CellValuePushed
VirtualMode
CellValueChanged
EndEdit
その他の技術情報
DataGridView コントロール (Windows フォーム)



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DataGridView.CommitEdit メソッド」の関連用語

DataGridView.CommitEdit メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridView.CommitEdit メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS