如何将焦点设置为Datagrid中的新数据行 [英] How do set the focus to a new datarow in a Datagrid
本文介绍了如何将焦点设置为Datagrid中的新数据行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我有一个数据网格填充数据和一个添加空行的按钮
按下按钮后,我希望在数据网格上的记录中添加一条记录。并专注于该记录。
Hello
I have a datagrid filled with data and a button to add an empty row
After I pressed the button, I want a record is added to our catalog on the data grid. And focus on that record.
Private Sub Button_Click_2(sender As Object, e As RoutedEventArgs)
Dim dr As DataRow
dr = dtGrid.NewRow()
dr("Status") = 4
dr("ID") = "0"
dr("Name") = ""
dr("CountryId") = "0"
dtGrid.Rows.Add(dr)
DG.SelectedItem = dtGrid.Rows.Count - 1
'' Make the ID field the current column of the grid
DG.CurrentColumn = DG.Columns(1)
'' Put the grid into editing mode
DG.BeginEdit()
'' Give the grid control focus
DG.ScrollIntoView(dr)
DG.BeginEdit()
end sub
如何关注该记录
谢谢
How do i get the focus on that record
Thanks
推荐答案
但我有一个问题。如果我按下Button_Click_2按钮,将在数据网格中插入一行。这很好。
但是第1列中的单元格没有进入editmode。
我该怎么做......
But i have a question. If i push the button 'Button_Click_2' there will be a row inserted in the datagrid. That is good.
But the cell in column 1 doesn't go in editmode.
What must i do ...
这篇关于如何将焦点设置为Datagrid中的新数据行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文