DataGrid.BeginEdit(DataGridColumnStyle, Int32) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
편집이 허용되는 상태로 그리드를 넣으려고 시도합니다.
public:
virtual bool BeginEdit(System::Windows::Forms::DataGridColumnStyle ^ gridColumn, int rowNumber);
public bool BeginEdit(System.Windows.Forms.DataGridColumnStyle gridColumn, int rowNumber);
abstract member BeginEdit : System.Windows.Forms.DataGridColumnStyle * int -> bool
override this.BeginEdit : System.Windows.Forms.DataGridColumnStyle * int -> bool
Public Function BeginEdit (gridColumn As DataGridColumnStyle, rowNumber As Integer) As Boolean
매개 변수
- gridColumn
- DataGridColumnStyle
편집할 A DataGridColumnStyle 입니다.
- rowNumber
- Int32
편집할 행의 수입니다.
반품
해당 메서드에 성공하면 true이고, 그렇지 않으면 false입니다.
구현
예제
다음 코드 예제에서는 메서드를 BeginEdit 사용 하 여 지정 된 열 및 행을 변경 하기 전에 편집 가능한 경우 테스트 합니다.
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 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
설명
사용자가 이미 셀에 입력을 시작한 경우 표에서 편집 요청을 거부합니다. 이 경우 메서드는 .를 BeginEdit 반환 false합니다.