Change Hover Color

7 posts, 0 answers
  1. Andrés
    Andrés avatar
    6 posts
    Member since:
    Nov 2012

    Posted 09 Nov 2012 Link to this post

    Hi!

    How can I change the hover color in GridView. I want change the hover color and selected color.

    I have a code in  like this:

    if(myCondition ==true)
     {
             e.RowElement.DrawFill = true;
             e.RowElement.GradientStyle = GradientStyles.Solid;
             e.RowElement.BackColor = System.Drawing.Color.LightSteelBlue;
             e.RowElement.ForeColor = System.Drawing.Color.Black;
    }
    else
    {
              e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
              e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
              e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
              e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
    }

    thanks
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 09 Nov 2012 Link to this post

    Hello,

    Please take a look at this thread.

    If you have any other questions, please let me know.

    Best Regards,
    Emanuel Varga
    WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Andrés
    Andrés avatar
    6 posts
    Member since:
    Nov 2012

    Posted 09 Nov 2012 Link to this post

    Hi, thanks for your answer;

    But in those threads talking about changing the topic of grid. I do not want to change the theme of the grid, I want to make a special treat as I do when loading rows.

    Thanks
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 09 Nov 2012 Link to this post

    Hello again,

    In my first reply there is a link to a code sample on how to change hover for the header cell, it should work with a minimum of changes for the rows hover.

    Let me know if you have any issues in accomplishing this.

    If you have any other questions, please let me know.

    Best Regards,
    Emanuel Varga
    WinForms MVP
  6. Plamen
    Admin
    Plamen avatar
    132 posts

    Posted 14 Nov 2012 Link to this post

    Hello,

    Thank you for writing.

    Attached you can find a sample demo application which demonstrates how to change the hover color of the rows. I am using the MouseMove and the CellFormatting event for that purpose. 

    More information regarding the formatting abilities of RadGridView can be found here: Formatting Rows.

    I hope that you find the provided information useful. Do not hesitate to contact us if you have any additional questions.

    Kind regards, Plamen
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.



  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 14 Nov 2012 Link to this post

    Hello guys,

    One little comment on this, you are hovering over a row and move the mouse out to the right of the grid area or form, the hover color will still be applied on the row, i would suggest adding the MouseLeave event also, where to set the lastHoveredCell.Tag to null, invalidate the cell and clear the lastHoveredCell, like so:

    void grid_MouseLeave(object sender, EventArgs e)
    {
        if (lastHoveredCell != null)
        {
            lastHoveredCell.RowInfo.Tag = null;
            lastHoveredCell.RowInfo.InvalidateRow();
        }
        lastHoveredCell = null;
    }

    Best Regards,
    Emanuel Varga
    WinForms MVP
  8. Plamen
    Admin
    Plamen avatar
    132 posts

    Posted 16 Nov 2012 Link to this post

    Hi guys,

    I agree that this case should be handled as well. Thank you, Emanuel.

    Greetings,
    Plamen
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top
UI for WinForms is Visual Studio 2017 Ready