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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
tricks801Author Commented:
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
That's because you're setting the Focus style, in your example, you could set the Highlight style instead:

      tblView.Styles.Highlight.BackColor = SystemColors.Highlight

You can also set an entire row or column to a new style that you create using the following syntax

    Dim FixedStyle As C1.Win.C1FlexGrid.CellStyle

     ' clear out any previously set style attributes
      tblView.Redraw = False

      FixedStyle = tblView.Styles.Add("FauxFixed")
      FixedStyle.BackColor = Color.WhiteSmoke

      tblView.Cols(0).Style = tblView.Styles("FauxFixed")
      tblView.Rows(0).Style = tblView.Styles("FauxFixed")

      tblView.Redraw = True

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.