您的位置:首页 > 其它

gridControl选中某列进行排序时,怎么能让那列高亮显示

2011-02-13 22:30 721 查看
winform:

首先捕获"EndSorting"事件,然后在其中加入以下代码:

private void gridView_EndSorting(object sender, EventArgs e)
{

Color clr = gridView.Appearance.Row.BackColor;
foreach (DevExpress.XtraGrid.Columns.GridColumn dc in gridView.Columns)
{
if (dc.VisibleIndex == gridView1.SortedColumns[0].VisibleIndex)
{
dc.AppearanceCell.BackColor = Color.Red;
}
else
{
dc.AppearanceCell.BackColor = clr;
}
}
}

其中的"gridView"是"DevExpress.XtraGrid.Views.Grid.GridView"类型实例

webfrom:

在DataGrid的SortCommand事件加入以下代码:

foreach(DataGridColumn dgc in dg.Columns)
{
if (dgc.SortExpression == e.SortExpression)
{
dgc.ItemStyle.BackColor = Color.Red;
}
else
{
dgc.ItemStyle.BackColor = Color.White;
}
}

其中dg是DataGrid的实例,e是SortCommand事件传入的DataGridSortCommandEventArgs类型参数

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ILOVEMSDN/archive/2006/09/05/1178875.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: