Link to home
Start Free TrialLog in
Avatar of tricks801
tricks801

asked on

C1 Flex Grid - Focus Style and HIghlight Style

i have a component one flex grid with three columns.

I want to set the whole row to be blue with white text when the user selects that row and gray with black text when the grid loses focus.
Avatar of mdougan
mdougan
Flag of United States of America image

You can do it at design time, buy highlighting the grid, expanding the Styles property, then looking for the Highlighted style and setting the background and forecolor properties.  Then, you can set the same properties for the Normal style for when the row is not highlighted.  You can also set these styles at run time, let me know if you need the code for that.

The key is figuring out which style to set... you said, "when the grid loses focus", did you mean when the row is no longer highlighted?  Or when the whole grid loses focus?  I don't believe that the grid has a built-in style for this, so, you'd probably have to alter the Normal style when the control gets a Lost Focus and a Got Focus event.

Also, I don't believe the grid has a built-in style for "selected" rows.  Typically, rows selected by the user clicking them become highlighted, and so it is the Highlighted style you want to set... however, I seem to remember cases where things might be selected in code, but do not appear highlighted on the screen.

Once you know which styles you want to set, let me know and I can show you code for setting them at runtime if you need to... and/or, if you want to create a new style and apply that to any part of the grid, I can show you how to do that too.
Avatar of tricks801
tricks801

ASKER

Im familiar with the Styles properties. The problem with these are that  they are of type CellStyleCollection, so they only affect one cell at a time.

Ex. .Styles.Focus.BackColor = SystemColors.Highlight will only set the color of the selected cell.

I decided to use the TrueDB grid. thanks
ASKER CERTIFIED SOLUTION
Avatar of mdougan
mdougan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial