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

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

DataGrid.BeginEdit メソッド

グリッド編集できる状態に移行するよう試みます

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

Public Function BeginEdit ( _
    gridColumn As DataGridColumnStyle, _
    rowNumber As Integer _
) As Boolean
Dim instance As DataGrid
Dim gridColumn As DataGridColumnStyle
Dim rowNumber As Integer
Dim returnValue As Boolean

returnValue = instance.BeginEdit(gridColumn, rowNumber)
public bool BeginEdit (
    DataGridColumnStyle gridColumn,
    int rowNumber
)
public:
virtual bool BeginEdit (
    DataGridColumnStyle^ gridColumn, 
    int rowNumber
) sealed
public final boolean BeginEdit (
    DataGridColumnStyle gridColumn, 
    int rowNumber
)
public final function BeginEdit (
    gridColumn : DataGridColumnStyle, 
    rowNumber : int
) : boolean

パラメータ

gridColumn

編集する DataGridColumnStyle。

rowNumber

編集する行の番号

戻り値
このメソッド成功した場合trueそれ以外場合false

解説解説
使用例使用例

BeginEdit メソッド使用して指定した列と行を変更する前に編集できるかどうかテストするコード例次に示します

Private Sub EditGrid(dataGrid1 As
 DataGrid)
    ' Get the selected row and column through the CurrentCell.
    Dim colNum As Integer
    Dim rowNum As Integer
    colNum = dataGrid1.CurrentCell.ColumnNumber
    rowNum = dataGrid1.CurrentCell.RowNumber
    ' Get the selected DataGridColumnStyle.
    Dim dgCol As DataGridColumnStyle
    dgCol = dataGrid1.TableStyles(0).GridColumnStyles(colNum)
    ' Invoke the BeginEdit method to see if editing can begin.
    If dataGrid1.BeginEdit(dgCol, rowNum) Then
        ' Edit row value. Get the DataTable and selected row.
        Dim myTable As DataTable
        Dim myRow As DataRow
        ' Assuming the DataGrid is bound to a DataTable.
        myTable = CType(dataGrid1.DataSource, DataTable)
        myRow = myTable.Rows(rowNum)
        ' Invoke the Row object's BeginEdit method.
        myRow.BeginEdit()
        myRow(colNum) = "New Value"
        ' You must accept changes on both DataRow and DataTable.
        myRow.AcceptChanges()
        myTable.AcceptChanges()
        dataGrid1.EndEdit(dgCol, rowNum, False)
    Else
        Console.WriteLine("BeginEdit failed")
    End If
End Sub 'EditGrid
private void EditGrid(DataGrid dataGrid1){
    // Get the selected row and column through the CurrentCell.
    int colNum;
    int rowNum;
    colNum = dataGrid1.CurrentCell.ColumnNumber;
    rowNum = dataGrid1.CurrentCell.RowNumber;
    // Get the selected DataGridColumnStyle.
    DataGridColumnStyle dgCol;
    dgCol = dataGrid1.TableStyles[0].GridColumnStyles[colNum];
    // Invoke the BeginEdit method to see if editing can begin.
    if (dataGrid1.BeginEdit(dgCol, rowNum)){
       // Edit row value. Get the DataTable and selected row.
       DataTable myTable;
       DataRow myRow;
       // Assuming the DataGrid is bound to a DataTable.
       myTable = (DataTable) dataGrid1.DataSource;
       myRow = myTable.Rows[rowNum];
       // Invoke the Row object's BeginEdit method.
       myRow.BeginEdit();
       myRow[colNum] = "New Value";
       // You must accept changes on both DataRow and DataTable.
       myRow.AcceptChanges();
       myTable.AcceptChanges();
       dataGrid1.EndEdit(dgCol, rowNum, false);
    }
    else{
      Console.WriteLine("BeginEdit failed");
    }
 }
 
private:
   void EditGrid( DataGrid^ dataGrid1 )
   {
      // Get the selected row and column through the CurrentCell.
      int colNum;
      int rowNum;
      colNum = dataGrid1->CurrentCell.ColumnNumber;
      rowNum = dataGrid1->CurrentCell.RowNumber;
      // Get the selected DataGridColumnStyle.
      DataGridColumnStyle^ dgCol;
      dgCol = dataGrid1->TableStyles[ 0 ]->GridColumnStyles[ colNum ];
      // Invoke the BeginEdit method to see if editing can begin.
      if ( dataGrid1->BeginEdit( dgCol, rowNum ) )
      {
         // Edit row value. Get the DataTable and selected row.
         DataTable^ myTable;
         DataRow^ myRow;
         // Assuming the DataGrid is bound to a DataTable.
         myTable = (DataTable^)(dataGrid1->DataSource);
         myRow = myTable->Rows[ rowNum ];
         // Invoke the Row object's BeginEdit method.
         myRow->BeginEdit();
         myRow[ colNum ] = "New Value";
         // You must accept changes on both DataRow and DataTable.
         myRow->AcceptChanges();
         myTable->AcceptChanges();
         dataGrid1->EndEdit( dgCol, rowNum, false );
      }
      else
      {
         Console::WriteLine( "BeginEdit failed" );
      }
   }
private void EditGrid(DataGrid myGrid)
{
    // Get the selected row and column through the CurrentCell.
    int colNum;
    int rowNum;

    colNum = dataGrid1.get_CurrentCell().get_ColumnNumber();
    rowNum = dataGrid1.get_CurrentCell().get_RowNumber();
    // Get the selected DataGridColumnStyle.
    DataGridColumnStyle dgCol;
    dgCol = dataGrid1.get_TableStyles().get_Item(0).get_GridColumnStyles().
        get_Item(colNum);

    // Invoke the BeginEdit method to see if editing can begin.
    if (dataGrid1.BeginEdit(dgCol, rowNum)) {
        // Edit row value. Get the DataTable and selected row.
        DataTable myTable;
        DataRow myRow;
        // Assuming the DataGrid is bound to a DataTable.
        myTable = (DataTable)(dataGrid1.get_DataSource());
        myRow = myTable.get_Rows().get_Item(rowNum);
        // Invoke the Row object's BeginEdit method.
        myRow.BeginEdit();
        myRow.set_Item(colNum, "New Value");
        // You must accept changes on both DataRow and DataTable.
        myRow.AcceptChanges();
        myTable.AcceptChanges();
        dataGrid1.EndEdit(dgCol, rowNum, false);
    }
    else {
        Console.WriteLine("BeginEdit failed");
    }
} //EditGrid
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGrid.BeginEdit メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGrid.BeginEdit メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGrid.BeginEdit メソッド を検索

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS