当用户双击列标题时,我必须选中/取消选中列中的所有复选框(切换)。
如何在DevExpress DxGrid控件中实现此行为?
我已经搜索了DevExpress支持论坛,但我还没有找到解决方案。
另外,我正在研究MVVM模式。
发布于 2011-09-20 15:50:19
这个案例适用于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
}
}但您必须注意,此操作不会阻止列的标题所做的排序,您可能需要禁用此网格的排序
希望这能帮上忙。
https://stackoverflow.com/questions/7481608
复制相似问题