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

change cell color

1 Answer 152 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mohammed abdel-aziz
Top achievements
Rank 1
mohammed abdel-aziz asked on 27 Jan 2010, 02:19 PM
please i need to change color of a certain cell ,how can i do that ,i have the column name and the row index

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 01 Feb 2010, 03:03 PM
Hello mohammed abdel-aziz,

Thank you for your question. You can format cell visual appearing in CellFormatting event. Please, consider the following code:

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.ColumnIndex == 2 && e.CellElement.RowIndex == 1)
    {
        e.CellElement.DrawFill = true;
        e.CellElement.BackColor = Color.LightBlue;
        e.CellElement.GradientStyle = GradientStyles.Solid;
    }
    else
    {
        e.CellElement.DrawFill = false;
        e.CellElement.ResetValue(VisualElement.BackColorProperty);                
    }
  
}

You can find additional info in our documentation. Write me back if you have any additional questions.

Regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
mohammed abdel-aziz
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or