【问题标题】:DevExpress XtraGrid - Cannot select Master RowDevExpress XtraGrid - 无法选择主行
【发布时间】:2013-03-28 17:42:54
【问题描述】:

我有一个 gridView,每个主行都有 1 对 1 的主从关系。当用户点击 detail 视图时,我想确保主行也被激活(在最左边的列中有激活的图标):

如果我使用键盘导航主网格和详细网格,这可以正常工作,但不能使用鼠标。所以我写了以下代码来尝试解决这个问题,但它不起作用。此代码是通过详细视图的点击事件触发的:

GridView focusedView = gridView3.GridControl.FocusedView as GridView;

// get the currently selected row in the child view
int focusedRowHandle = focusedView.FocusedRowHandle;

// get the parentView's row handle that owns the child view
int sourceRowHandle = focusedView.SourceRowHandle;

GridView parentView = focusedView.ParentView as GridView;
parentView.BeginSelection();
parentView.SelectRow(sourceRowHandle);
parentView.EndSelection();

谁能告诉我我做错了什么?

【问题讨论】:

    标签: c# winforms devexpress xtragrid


    【解决方案1】:

    您是否使用单行选择模式?如果禁用了多选(ColumnViewOptionsSelection.MultiSelect 选项设置为false),SelectRow 方法什么都不做

    使用ColumnView.FocusedRowHandle 属性选择拥有详细视图的主行。

    相关文章:Selection Overview

    【讨论】:

    • SelectRow 似乎可以工作,但它总是选择所有主行的第一行。不知道是不是因为我在连续点击事件期间使用了上述逻辑。
    猜你喜欢
    • 1970-01-01
    • 2018-03-24
    • 1970-01-01
    • 1970-01-01
    • 2017-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-27
    相关资源
    最近更新 更多