We're using 8.3 and we need to remove the row selection bar from some of our grids without completely disabling app styling (we also do not need row selection for these grids - they are just for display purposes).
Looking at another post, I tried the following:
grd.DisplayLayout.Override.ActiveRowAppearance.Reset()
grd.DisplayLayout.Override.SelectTypeRow = SelectType.None
These don't work unless I set AppStyling to False, which doesn't look good. Can I keep AppStyling and still get the effect I want?
Hi Amber,
To turn off row selection, you can use:
You are already doing that. So my guess is that your ActiveRow is being highlighted in the grid because of your application style.
So there are a couple of ways you could get around this:
1) Modify the Application Style Library so that it does not apply an appearance to the ActiveRow. You would probably lookat the GridRow or UltraGridRow UIRole and modify the Active state to remove whatever settings are applied.
2) Use a DrawFilter to override the Drawing of the row.
A lot of the grids in our application need an active row style, plus we have a lot of different styles that we offer our users. Are you suggesting that we make copies of all our styles, remove the active row setting in each copy, figure out which style the user is using and assign the correct copy to the handful of grids that need to have the active row style removed? Or is there some way to do this in code?
As for a draw filter, can you provide a brief example of how to do that? Are there any 'side effects' from using a draw filter?
Well, ApplStylist is intended to style the entire application, not just a single control. So there's no way to turn off one single state of a role on some controls and not others.
Since the grid always has an ActiveRow, there's really no way to handle this. I suppose we could add a property to the grid that determines whether or not it honors the ActiveRowAppearance or not. But at present, there is no such property.
You don't necessarily have to create two copied of each style library. You could create StyleSets within each Style Library. One StyleSet could apply styling to the active row and the other could simply leave that out. In fact, you can base on StyleSet on another. So you could have a base StyleSet without any ActiveRow styling on it. Then you could create a second StyleSet based on the first one with ActiveRow appearances applied to it. Then you set the StyleSetName on the grid's you want to show an ActiveRow.
So, the existing style libraries you are using probably each have a single StyleSet. So all you would have to do is add a second one based on the existing one. Then copy the ActiveRow style from the existing one to the new one, and clear those settings on the existing StyleSet.
amberfontes said:As for a draw filter, can you provide a brief example of how to do that? Are there any 'side effects' from using a draw filter?
The DrawFilter would be a bit complex. I don't have a sample of this exactly, but there's a sample of how to remove the selected appearance from a row using a DrawFilter here: DrawFilter for Backcolor - Infragistics Forums
So you would need to handle Active, instead of Selected, and you would also need to figure out how to determine the appearance of the cell in a non-active state. It would not be a trivial task, I'm afraid.
Okay, Mike. Thank you for explaining this - I really appreciate it.
On the other hand, I have to admit, there should be an easier way to do this. Having a grid where the information is for display-only purposes and, therefore, doesn't need an active row, is a common UI feature. There should a property or override that can handle this. I will submit a feature request.
For what it's worth, I agree with you. This kind of issue comes up more and more often as more developers start using AppStylist. So we really do need to make this easier and I am hoping we can do something about this in the next release.