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

How to remove focus rectangle from selected cell

14 Answers 970 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Geoff Hardy
Top achievements
Rank 1
Geoff Hardy asked on 03 Aug 2010, 11:13 PM
I recently upgraded from the 2010 Q1 controls to the 2010 Q2 controls. One change to the RadGridView that I have noticed is that when you click on a cell, a black rectangle is drawn around the cell to indicate that the cell has focus.

This is good in many cases, except for some grids which are read-only. In this case, I just want to select the entire row but not set focus on the cell that was clicked. In other words, I do not want the black focus rectangle to show up at all. I have SelectionMode="Single" and SelectionUnit="FullRow", but this does not appear to have any effect on whether or not the focus rectangle shows up.

Is there an easy way to turn off this focus rectangle?

14 Answers, 1 is accepted

Sort by
0
Kalin Milanov
Telerik team
answered on 04 Aug 2010, 09:46 AM
Hi Geoff Hardy,

To do that you will need to edit the template of the cell and change the focus visual state to handle this case. 
Attached I am sending you a sample to get you started. 

Best wishes,
Kalin Milanov
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
Geoff Hardy
Top achievements
Rank 1
answered on 04 Aug 2010, 03:56 PM
Thanks Kalin. This solution does indeed work.

Is this this simplest way to achieve this? Any time I have to add 200 lines of xaml to do something that seems like it should be a line line change, I start to wonder if there is an easier way. Adding all that extra xaml seems somewhat convoluted and I am not sure that there is any guarantee that it will all work OK in future versions of the RadGridView. Also, I don't really understand what was changed in the control template.

I thought maybe there would be a way to do it by defining a SolidColorBrush resource with the right name, that the grid would use when drawing the focus rectangle around the current cell?
0
Kalin Milanov
Telerik team
answered on 05 Aug 2010, 12:54 PM
Hello Geoff Hardy,

More often than not we are facing the "Chicken or the Egg" problem. The case with marking the current cell is no different. We went through many iterations on this how to present the visual for the current cell in an unobtrusive way. What you see is the result of a great deal of customer feedback collected for over a year ultimately leading us to believe that we would rather have it visible as it is easier to remove it than create it from scratch.

On the matter of simplicity - actually this is the simplest way to achieve this. You can also do it in code, but the logic of it would be far more complex (with less lines true) than this. On a side note this is the natural way of restyling controls and 200 lines of XAML look scarier than they actually are. 

As for what was changed - there is a Current visual state which by default contains an animation setting the visibility of the Background_Current border to visible. I have just removed that animation to get the desired result.

Any feedback on this is greatly appreciated as we are always looking into ways of improving our controls.

All the best,
Kalin Milanov
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
bruno
Top achievements
Rank 1
answered on 09 Sep 2010, 06:57 PM
I have the same problem.

I can't open that project, because i am using visual studio 2008.
What i have to do to apply that XAML in my project?
0
bruno
Top achievements
Rank 1
answered on 10 Sep 2010, 10:50 AM
Ups... my problem is in Windows Form. Only now i noticed  that this is in Silverlight.
0
bruno
Top achievements
Rank 1
answered on 10 Sep 2010, 11:59 AM
I solved my problem doing this:

...
radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting);
...


void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
      e.CellElement.DrawBorder = false;
}
0
Aaron
Top achievements
Rank 1
answered on 07 Dec 2010, 06:54 PM
I would like to second Geoff's frustration with the fact that this property is not exposed without having to 'override' (probably not the best way to call it) the control's properties. One issue I see with this is that once you edit the template, all the properties are now hardcoded so any upgrades to the control will need manual updates to the template. In my situation my project's gridview is readonly so for me it's just an annoyance the fact that it highlights the cell since it serves no purpose.
Aaron
0
Odin
Top achievements
Rank 1
answered on 12 Jan 2011, 07:07 PM
Kalin,

you wrote " you will need to edit the template of the cell and change the focus visual state"...sorry but I did not find visual state Focus in the code. It is still a mystery to me how it works.

Thank you,
   odin...
0
Vanya Pavlova
Telerik team
answered on 13 Jan 2011, 02:37 PM
Hello Geoff,

Focus VisualStyle property is related to WPF. You will find an example in our online documentation how to remove focus visual style, following this link:
http://www.telerik.com/help/wpf/how-to-override-default-gridview-styles.html

On the other hand if you are using RadGridView/Silverlight, follow this link:
http://www.telerik.com/help/silverlight/how-to-override-default-gridview-styles.html

 


All the best,
Vanya Pavlova
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Guillermo
Top achievements
Rank 1
answered on 07 Sep 2012, 07:33 PM
Hi, in the last version Q1 2012 SP1 how cant i acomplish remove focus rectangle from cell ?
I am using the Vista theme

0
Timothy
Top achievements
Rank 1
answered on 06 Jul 2015, 09:41 PM
I am going to second has already been said above.
0
Leonid
Top achievements
Rank 1
answered on 07 Jul 2015, 07:17 AM

Hello,

 Is there a better solution for removing the cell border without editing the GridViewCell style? 

0
Dimitrina
Telerik team
answered on 08 Jul 2015, 01:44 PM
Hi,

You can control the visibility of all grid lines through configuring RadGridView's GridLinesVisibility property.

Otherwise, as to removing the current border/focus rectangle, I am afraid there is not a setting to suggest.
You can either Edit the Control Template as explained in the article or directly modify the specific template in Themes/Telerik.Windows.Controls.GridView.xaml file. The second approach is illustrated in Setting a Theme (Using Implicit Styles).  

Regards,
Dimitrina
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Tim
Top achievements
Rank 1
answered on 26 Jan 2016, 04:10 PM
I created a feedback item about this issue. You might want to vote.
Tags
GridView
Asked by
Geoff Hardy
Top achievements
Rank 1
Answers by
Kalin Milanov
Telerik team
Geoff Hardy
Top achievements
Rank 1
bruno
Top achievements
Rank 1
Aaron
Top achievements
Rank 1
Odin
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Guillermo
Top achievements
Rank 1
Timothy
Top achievements
Rank 1
Leonid
Top achievements
Rank 1
Dimitrina
Telerik team
Tim
Top achievements
Rank 1
Share this question
or