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

Conditional Formating

1 Answer 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 04 Sep 2007, 06:22 AM
Is there a way to use conditional formating to detect if a non number is entered into a cell?

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 04 Sep 2007, 04:25 PM
Hello Tony De Wit,

Thank you for this question.

This is a complex condition and can't be done using standard conditional formating. To have more control over formatting conditions, you should use the CellFormatting event. The following code presents a solution to your case:

this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting);

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.ColumnInfo.UniqueName == "SomeColumn")
    {
        int result = 0;
        if (!int.TryParse((string)e.CellElement.Value, result))
            e.CellElement.BackColor = Color.Red;
    }
}

Best wishes,
Jack
the Telerik team

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