在 C# 中使用 xeed datagrid 将焦点更改到下一个单元格
我是 C Sharp 编程新手。我需要对我们的项目进行更改。基本上我们使用的是 Xeed 数据网格,它有 4 列。数据与集合对象绑定,并通过数据库调用动态更新。我的问题共 4 列,其中 1 列是可编辑的。当用户在此列中进行更改并按 Enter 键时,焦点需要在编辑模式下更改到同一列中的下方单元格。以下是我正在编写的 KeyUp 事件。在我更改此列并按 Enter 键后,焦点将转到下一行,但编辑模式不会转到下一个单元格,而是保留在已编辑的同一单元格上。
private void _dataGrid_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
_dataGrid.EndEdit();
int currentRow = _dataGrid.SelectedIndex;
currentRow++;
_dataGrid.SelectedIndex = currentRow;
_dataGrid.Focus() ;
_dataGrid.BeginEdit();
}
}
I am new to C sharp programming. I need to make a change in our project. Basically we are using Xeed datagrid, which has 4 columns. Data is bound with the collection object and was updated dynamically with DB call. My question is out of 4 columns, 1 column is editable. when user make a change in this column and hit enter, the focus needs to change to below cell in the same column in the edit mode. Following is the KeyUp event I am writting. After I make change this columna nd hit enter the focus is going to next row, but the edit mode is not going to next cell, but instead stays on the same cell which was eddited.
private void _dataGrid_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
_dataGrid.EndEdit();
int currentRow = _dataGrid.SelectedIndex;
currentRow++;
_dataGrid.SelectedIndex = currentRow;
_dataGrid.Focus() ;
_dataGrid.BeginEdit();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您需要更改 CurrentItem 属性。我使用不同的网格控制,所以我不保证它会起作用。但程序应该是这样的:
I think you need to change CurrentItem property. Iam using different grid control so I not guaranty that it will work. But procedure should be something like this:
遵循解决方案
Following the solution