Articles in this section
Category / Section

How to change the background of RowHeader based on business logic?

2 mins read

RowHeader is a special Column used to indicate the row status like Current Row and you can enable or disable the RowHeader by setting the ShowRowHeader property in GridDataControl.

RowHeader allows you to customize the background based on the business logic .The following screenshot displays the default format of RowHeader.

Default RowHeader

Figure 1: Default style of RowHeader

You can change the background color of RowHeader Cell by using QueryCellInfo event that is used to customize each and every cell in the required format and the event is raised for each cell that requires redrawing. This is illustrated in the following code example.

C#

void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
        {
            //You have to skip Header Row whose row index value is zero 
            if (e.Style.RowIndex > 0)
            {
             //The styles are applied for RowHeaderCell by checking the Column index is  zero or not  (RowHeaderCell  column index is 0)
                if (e.Style.ColumnIndex == 0)
                {
                    //Render the record index from the value of the Rowindex  
                    int recordindex =   this.gridDataControl.Model.ResolveIndexToRecordPosition(e.Style.RowIndex);
                    //Here the record retrieved  based on the record index position 
                    var record = this.gridDataControl.Model.View.Records[recordindex];
                    //Apply color by checking whether the Business object Status equals true 
                    if ((record.Data as Data).Status.Equals(true))
                    {
                        e.Style.Background = Brushes.Pink;
                    }
                }
            }
        }

Execute the above code to change the RowHeader’s default color into pink color whose corresponding status cell value is true that is illustrated in the following screenshot.

Setting RowHeader Color

Figure 2: Background customization of RowHeader

Please refer the following sample for to change the background of Row header based on the business logic.

Sample Link: BackGroundColor_of_RowHeader(GDC)

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied