gpt4 book ai didi

c# - 在devexpress xtragrid中单击columnheader时选择columnwise?

转载 作者:行者123 更新时间:2023-11-30 23:08:49 25 4
gpt4 key购买 nike

我正在使用 devexpress 16.1,我将我的数据表绑定(bind)到 xtragrid,现在我想在单击列标题时按列选择,如果有任何选项可以通过 xtragrid 实现此目的的话。

这些都是我尝试过的,

gridview1.optionsselection.multiselect = True
gridview1.optionsselection.multiselectMode = cellselect

最佳答案

试试这段代码:(使用 Gridcontrol 鼠标按下事件)

VB.net:
Dim hitInfo = GridView1.CalcHitInfo(e.Location)
If e.Button = Windows.Forms.MouseButtons.Left Then
For Each column As GridColumn In GridView1.Columns
If column.FieldName = hitInfo.Column.FieldName Then
hitInfo.Column.AppearanceCell.BackColor = Color.FromArgb(226, 234, 253)
Else
GridView1.Columns(column.FieldName).AppearanceCell.BackColor = Nothing
End If
Next
End If

C#:
var hitInfo = GridView1.CalcHitInfo(e.Location);
if (e.Button == Windows.Forms.MouseButtons.Left)
{
foreach (GridColumn column in GridView1.Columns)
{
if (column.FieldName == hitInfo.Column.FieldName)
{
hitInfo.Column.AppearanceCell.BackColor = Color.FromArgb(226, 234, 253);
}
else
{
GridView1.Columns(column.FieldName).AppearanceCell.BackColor = null;
}
}
}

调用 GridView.CalcHitInfo 方法获取行句柄。然后焦点移动到该行并调用自定义上下文菜单。

关于c# - 在devexpress xtragrid中单击columnheader时选择columnwise?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46280676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com