DevExpress DXGrid列标题双击事件

时间:2011-09-20 07:33:42

标签: c# wpf devexpress

当用户双击列标题时,我必须检查/取消选中列中的所有复选框(切换)。

如何在DevExpress DxGrid控件中实现此行为?

我搜索过DevExpress支持论坛,但我还没有找到解决方案。

另外,我正在研究MVVM模式。

1 个答案:

答案 0 :(得分:1)

此案例适用于WinForms,尚未在WPF中测试过,我发布的可能会引导您进入某些灯光:

有一种解决方法可以实现此操作,您必须实现yourGrid_DoubleClick事件处理程序,然后计算鼠标单击的hit Info,命中信息对象将告诉您双击是否打开一栏,如:

 private void yourGridViewName_DoubleClick(object sender, EventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.GridView sndr =
                    sender as DevExpress.XtraGrid.Views.Grid.GridView;

            DevExpress.Utils.DXMouseEventArgs dxMouseEventArgs =
                e as DevExpress.Utils.DXMouseEventArgs;


            DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hitInfo =
               sndr.CalcHitInfo(dxMouseEventArgs.Location);

            if (hitInfo.InColumn)
            {
               string x = hitInfo.Column.Name;

              //Rest of your logic goes here after getting the column name, 
             //You might now loop over your grid's data and do your logic
           }
    }

但是你必须注意到这个动作不会阻止列标题的排序,你可能需要禁用这个网格的排序

希望这会有所帮助。

相关问题