0
我想在DataGrid中添加一个新行获得新的行电网
添加新行
我要添加新的行格,然后我想集中注意力于电网。像这样
grid1.addrow()
grid.newrow.focus() 'I want to focus into new row
如何做到这一点。
需要建议或代码帮助
我想在DataGrid中添加一个新行获得新的行电网
添加新行
我要添加新的行格,然后我想集中注意力于电网。像这样
grid1.addrow()
grid.newrow.focus() 'I want to focus into new row
如何做到这一点。
需要建议或代码帮助
这是一个非常原始的例子,因为我不知道该怎么跟你是什么填充您的DGV控制或(我假定你的意思“的DataGridView”当你说“网格” ):
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim dgv As DataGridView = Me.DataGridView1
Dim newRow As DataGridViewRow
Dim rowData() As String = {"John", "Doe"}
'Add a first row, just so we can see that this works:
newRow = dgv.Rows(dgv.Rows.Add(rowData))
newRow.Selected = False
' Now create some random data for the next row:
rowData(0) = "Mary"
rowData(1) = "Smith"
' Add the next row:
newRow = dgv.Rows(dgv.Rows.Add(rowData))
' Set the status of the first cell (element zero in the array of cells
' to Selected = true:
newRow.Cells(0).Selected = True
'If you want a reference to the active cell:
Dim cell As DataGridViewCell = newRow.Cells(0)
End Sub
这不是太多的工作,但你并没有给我们太多的与工作的。 。 。如果您可以多发布一段代码,或者更全面地解释您想要做的事情,我们可以提供更有建设性的反馈。
希望帮助!