本文整理汇总了VB.NET中System.Windows.Forms.DataGrid.BeginEdit方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DataGrid.BeginEdit方法的具体用法?VB.NET DataGrid.BeginEdit怎么用?VB.NET DataGrid.BeginEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGrid
的用法示例。
在下文中一共展示了DataGrid.BeginEdit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: EditGrid
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