This is a migrated thread and some comments may be shown as answers.

Conditional formatting problems.

1 Answer 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Miljenko
Top achievements
Rank 1
Miljenko asked on 17 Oct 2007, 07:09 AM

Hi.

I get problems with conditional formatting.

In the case that you want to set font color (CellForeColor) that depending on the column condition and you set property ‘Apply to row’ is true and also if you create second condition that changing row back color you will lose CellForeColor setup from first condition.

Is it possible to change dynamically “row back color” without using conditional formatting?



 

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 17 Oct 2007, 10:44 AM
Hello Miljenko,

We could not reproduce this issue locally. Maybe your second condition overrides settings from the first condition. Can you give us more details about these conditions?

Yes, there is a way to modify cell properties conditionally without using conditional formatting. This can be done using CellFormatting and RowFormatting events. These events occur when cell visual state needs to be updated.  See the following code:

this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting); 
 
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
    if (e.CellElement.ColumnInfo is GridViewDataColumn && 
        (e.CellElement.ColumnInfo as GridViewDataColumn).DataField == "Name"
    { 
        e.CellElement.BackColor = Color.Red; 
    } 
 


We hope this information solves your issue. If not, we will be glad to help you further.

Regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Miljenko
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or