DataGrid.BeginEdit メソッド
アセンブリ: 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)
- gridColumn
編集する DataGridColumnStyle。
このメソッドが成功した場合は 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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataGrid.BeginEdit メソッドを検索する場合は、下記のリンクをクリックしてください。

- DataGrid.BeginEdit メソッドのページへのリンク