3 Answers, 1 is accepted
0
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:
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
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
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
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.