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

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

你可能感兴趣的:(DEV组件包,datagrid,winform,object)