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

change cell focus color

3 Answers 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Niloofar
Top achievements
Rank 1
Niloofar asked on 30 Mar 2015, 03:57 PM
Hi,
I am wondering if there is anyway to change focus color for whole grid cells or is there any property for setting TableElement focus color?

cheers,

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 02 Apr 2015, 09:36 AM
Hi Niloofar,

Thank you for writing.

If I understand correctly you would like to change the BackColor of a cell if it is focused, i.e. selected or current. The easiest way to achieve this would be to subscribe to the CellFormatting event and in the handler apply the desired settings. An example is discussed here. Please also check my code snippet below:
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.IsCurrent && !this.radGridView1.IsInEditMode)
    {
        e.CellElement.DrawFill = true;
        e.CellElement.GradientStyle = GradientStyles.Solid;
        e.CellElement.BackColor = Color.LightBlue;
        e.CellElement.BorderColor = Color.Red;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BorderColorProperty, ValueResetFlags.Local);
    }
}

Another way to accomplish a similar result would involve modifying the theme which you are using. For this purpose you can use our Visual Style Builder tool. I am also sending you two screenshots, the first one is demonstrating how the RadGridView looks on my side after applying the code snippet and the other one is showing the grid`s element structure in the visual style builder as well as the different element states of the GridDataCellElement.

I hope this information is useful Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Niloofar
Top achievements
Rank 1
answered on 07 Apr 2015, 12:16 PM

I think editing theme seems to be a more efficient approach. Thank you for your solutions!

Regards,

Niloofar

0
Hristo
Telerik team
answered on 09 Apr 2015, 12:54 PM
Hi Nilofaar,

Indeed it is, using this approach would not require to handle the CellFormatting event. This way you can save resource and allocate them for some other task.

Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
GridView
Asked by
Niloofar
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Niloofar
Top achievements
Rank 1
Share this question
or