When gridcontrol selects a column for row sorting, how can it make the column highlighted?

Source: Internet
Author: User
Winform:

Add the following generation to the "endsorting" event of gridview1: 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:

Add the following generations to the DataGrid sortcommand event:

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}

 

The DG is the real example of the DataGrid, and E is the data of the datagridsortcommandeventargs type imported by the sortcommand event.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.