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

Change Hover Color

6 Answers 420 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrés
Top achievements
Rank 1
Andrés asked on 09 Nov 2012, 09:33 AM
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

6 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 09 Nov 2012, 09:41 AM
Hello,

Please take a look at this thread.

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

Best Regards,
Emanuel Varga
WinForms MVP
0
Andrés
Top achievements
Rank 1
answered on 09 Nov 2012, 09:53 AM
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 09 Nov 2012, 09:56 AM
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
0
Plamen
Telerik team
answered on 14 Nov 2012, 07:45 AM
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.



0
Emanuel Varga
Top achievements
Rank 1
answered on 14 Nov 2012, 12:50 PM
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
0
Plamen
Telerik team
answered on 16 Nov 2012, 01:43 PM
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.
Tags
GridView
Asked by
Andrés
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Andrés
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or