This is driving me insane... no matter what options I set for the grid it always selects the full row! I've tried the above code, and I've even used the designer to go through to selection styles but no matter what when I click a cell it is always selecting the full row. What am I doing wrong?
Chances are that your row is being "activated" instead of "selected." The default preset for the grid uses the same background color for the grid's active row as it does for selected rows.
See what happens when you set the following properties of your grid, so that the active row shows no background or foreground color:
.DisplayLayout.Override.ActiveRowAppearance.BackColor = Color.Empty.DisplayLayout.Override.ActiveRowAppearance.ForeColor = Color.Empty
That still didn't work:(
I have placed an event on keypress and looked at all the grid values at this time:
gExcelGrid.DisplayLayout.Override.ActiveRowAppearance.ForeColor "{Name=0, ARGB=(0, 0, 0, 0)}" System.Drawing.Color
gExcelGrid.DisplayLayout.Override.ActiveRowAppearance.BackColor "{Name=0, ARGB=(0, 0, 0, 0)}" System.Drawing.Color
gExcelGrid.DisplayLayout.Override.CellClickAction CellSelect Infragistics.Win.UltraWinGrid.CellClickAction
BCCollins said:I have placed an event on keypress and looked at all the grid values at this time
With that in mind, let me take a step back: what are you seeing in your application that is making you believe that clicking on a cell is selecting (as opposed to activating) an entire row, despite having set CellClickAction to CellSelect? Is this something you're seeing visually, or something you're seeing by inspecting one or more properties? If it's visual, could you attach a screenshot of what you're seeing (use the Options tab when posting), and if it's by looking at properties, which ones?
This is me trying to select a range of cells. Which over row I click on or wherever my mouse drags, the entire row is selected.
BCCollins said:Shouldn't setting the "Override" property take precedence over an application style?
Most application styles, including the ones we provide with the toolset, are set to resolve in the order of "application then control." This setting is called the "resolution order." This value means that, if the application style says to style something a certain way, any contrary settings on the control are ignored. This is to make it easier to drop an application style into an existing application. I suspect that this is what's affecting your application.
An alternative is to set the resolution order on the application style to "control then application," which would mean that settings on the control are used first (including properties on the Override object of the grid), and the application style is used only if the control doesn't say what to use.
Test to see if setting the UseAppStyling property of the grid to false so that it'll ignore all application styling.
If that works, then we can look more closely to see how to "surgically" tell this specific grid to not color the active row, without affecting other grids or disabling application styling for this grid altogether. My current idea is to define a new resource in the style library, and to use the grid's DisplayLayout.Override.ActiveRowAppearance.StyleResourceName property to apply that specific resource for the grid's active row.
You might be right, I never thought of that. This is a very big application and the colour scheme of this grid seems to match all the others. I'm guessing this grid would still need to follow that style, but I would need this one property(full row selection) to be overridden. Shouldn't setting the "Override" property take precedence over an application style?
Thanks, this screenshot helps significantly.
That highlighted row is likely "active" rather than "selected". You've set the appearance properties I've mentioned that should make the active row have no effect on background/foreground color, and that doesn't seem to be working.
Are you using application styling on your project? If so, the application style is likely taking precedence over the appearance properties you've set on the control.