change cell focus color

4 posts, 0 answers
  1. Niloofar
    Niloofar  avatar
    24 posts
    Member since:
    Jan 2015

    Posted 30 Mar 2015 Link to this post

    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,
  2. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 02 Apr 2015 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Niloofar
    Niloofar  avatar
    24 posts
    Member since:
    Jan 2015

    Posted 07 Apr 2015 in reply to Hristo Merdjanov Link to this post

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

    Regards,

    Niloofar

  5. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 09 Apr 2015 Link to this post

    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.

     
Back to Top