select 在 devexpress xtragrid 中单击列标题时按列排列?
select columnwise while click columnheader in devexpress xtragrid?
我正在使用 devexpress 16.1,我将我的数据表绑定到 xtragrid,
现在我想按列 select,同时单击列 header,如果有任何选项可以通过 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方法获取行句柄。然后焦点移动到此行并调用自定义上下文菜单。
我正在使用 devexpress 16.1,我将我的数据表绑定到 xtragrid, 现在我想按列 select,同时单击列 header,如果有任何选项可以通过 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方法获取行句柄。然后焦点移动到此行并调用自定义上下文菜单。