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

How do I disable the cell highlight in the grid view?

5 Answers 1707 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vithiya
Top achievements
Rank 1
Vithiya asked on 08 Apr 2010, 08:08 PM
I have the grid in 'FullRowSelect' mode. So the row is selected as a whole. But the active cell is still highlighted in a different color. How do I disable that? I just want the entire row to be highlighted without the current cell being highlighted in a different color.

Thanks,
Vithiya

5 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 13 Apr 2010, 10:17 AM
Hi Vithiya,

Thank you for contacting us.

In FullRowSelect mode the current cell is still highlighted because the grid has a different background style for the current cell in its theme. You can remove this style or you use CellFormatting event to disable background painting:
 
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.IsCurrent)
    {
        e.CellElement.DrawFill = false;
    }
}

Hope this helps. Let me know if you have any additional questions.

Greetings,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jason Richmeier
Top achievements
Rank 1
answered on 04 Oct 2010, 10:10 PM
I have been trying to determine a solution for this issue as well.

The code sample provided in the previous post does not appear to do anything (the cell is still highlighted).  It sounds as though there is an alternate approach.  Can you provide details on this approach?
0
Emanuel Varga
Top achievements
Rank 1
answered on 05 Oct 2010, 06:44 AM
Hello guys,

If you just want to disable OnHover you can just set:
radGridView1.EnableHotTracking = false;

If you have any more question, please do not hesitate.

Update, sorry i don't know how i got the idea that you just wanted to disable onhover...

But if you want to change the selection styles, or any other styles for that matter you should use VisualStyleBuilder(http://www.telerik.com/help/winforms/vsb_gettingstarted.html), there you can define whichever color styles you want.

Or you could just try:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.IsCurrent)
    {
        e.CellElement.IsCurrent = false;
    }
}

This way the current cell won't have that border, but it looks strange in my point of view...

Best Regards,
Emanuel Varga
0
Jason Richmeier
Top achievements
Rank 1
answered on 05 Oct 2010, 02:39 PM
I cannot speak for the original poster but I know in my case, I do not need to distinguish which cell is selected in the row but rather that an entire row is selected.  I could see highlighting the selected row being desired if the grid allowed in-place edits.  In my case, however, the grid data is read only.

I found that instead of the code...

e.CellElement.IsCurrent = false;

...the following code works more the way I want...

e.CellElement.DrawBorder = false;

e.CellElement.DrawFill = false;

 

0
Svett
Telerik team
answered on 07 Oct 2010, 05:42 PM
Hello Jason Richmeier,

The described solution will work, however we recommend resetting the values when the cell does not meet the conditions:


void
radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.IsCurrent)
    {
        e.CellElement.DrawFill = false;
        e.CellElement.DrawBorder = false;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.DrawBorderProperty, Telerik.WinControls.ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}

This should be done due to reusing of cell elements by the RadGridView.

If you have any further questions, please do not hesitate to ask.

Greetings, Svett
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Vithiya
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Jason Richmeier
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Svett
Telerik team
Share this question
or