Xceed DataGrid SelectedItem 问题
在我的项目中,我有一个 Xceed 数据网格,它绑定到包含许多记录和记录详细信息的数据源。我正在尝试创建一个上下文菜单选项,该选项将允许用户在特定列中搜索特定详细信息。虽然我已经成功完成了该功能,但有一个 UI 部分给我带来了一些麻烦,因为当我在 C# 中选择该行时,如果该行不在视图中,则该行永远不会受到关注。因此,用户必须上下滚动以查找具有扩展详细信息的行。
我可以设置 SelectedRow 并展开详细信息,如下所示:
this.grid.AutoFilterValues[userColumn].Clear();
this.grid.AutoFilterValues[userColumn].Add(userValue);
if (this.creditLinesDataGridControl.Items.Count > 0)
{
this.grid.SelectedItem = this.grid.Items[0];
this.grid.ExpandDetails(this.grid.Items[0]);
}
else
{
MessageBox.Show("Value not found in column: " + userColumn);
}
this.grid.AutoFilterValues[userColumn].Clear();
userColumn 和 userValue 是先前在方法中设置的。
设置 SelectedItem 并展开详细信息后,如何使网格集中在该行上?
谢谢,
帕特里克
In my project I have an Xceed data grid which is bound to a data source with many records and record details. I am attempting to create a context menu option that will allow the user to search for a specific detail in a specific column. While I have successfully completed the functionality there is a UI part that is giving me some trouble, in that when I select the row in C#, if that row is not in view the row is never focused on. Thus the user has to scroll up and down looking for the row with expanded details.
I am able to set the SelectedRow and expand the details like so:
this.grid.AutoFilterValues[userColumn].Clear();
this.grid.AutoFilterValues[userColumn].Add(userValue);
if (this.creditLinesDataGridControl.Items.Count > 0)
{
this.grid.SelectedItem = this.grid.Items[0];
this.grid.ExpandDetails(this.grid.Items[0]);
}
else
{
MessageBox.Show("Value not found in column: " + userColumn);
}
this.grid.AutoFilterValues[userColumn].Clear();
where userColumn and userValue are set previously in the method.
How can I make the grid focus on the row after I've set the SelectedItem and expanded the details?
Thanks,
Patrick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道 Xceed DataGrid 的 API,但通常此类类提供类似
ScrollIntoView(...)
的方法。经过一番谷歌搜索后,我发现 Xceed 的 DataGrid 显然提供了一个名为BringItemIntoView(...)
的方法。你试过那个吗?例如,在 Xceed 论坛的此帖子中,他们讨论了此方法。
I do not know the Xceed DataGrid's API, but typically such classes provide a method like
ScrollIntoView(...)
. After googling a bit, I found that Xceed's DataGrid obviously offers a method calledBringItemIntoView(...)
. Did you try that one?For example, in this thread in the Xceed forum they discuss this method.