GridControl 選中某列進行排序時,怎麼能讓那列高亮顯示

winform:


gridView1 "EndSorting" 事件中加入以下代碼:
 1 private   void  gridView1_EndSorting( object  sender, EventArgs e)
 2          {
 3            Color clr = gridView1.Appearance.Row.BackColor;
 4            foreach (DevExpress.XtraGrid.Columns.GridColumn dc in gridView1.Columns)
 5            {
 6                if (dc.VisibleIndex == gridView1.SortedColumns[0].VisibleIndex)
 7                {
 8                    dc.AppearanceCell.BackColor = Color.Red;
 9                }

10                else
11                {
12                    dc.AppearanceCell.BackColor = clr;
13                }

14            }

15        }


webfrom:

DataGridSortCommand事件加入以下代碼:

 1 foreach (DataGridColumn dgc  in  dg.Columns)
 2 {
 3 if (dgc.SortExpression == e.SortExpression)
 4 {
 5  dgc.ItemStyle.BackColor = Color.Red;
 6 }

 7 else
 8 {
 9  dgc.ItemStyle.BackColor = Color.White;
10 }

11}

 

其中dgDataGrid的實例,eSortCommand事件傳入的DataGridSortCommandEventArgs類型參數

你可能感兴趣的:(grid)