changing cellbackcolor when hitting the enter key in msflexgrid - use for navigating

currently, I can navigate the grid using the enter key. What  I need is to change the cellbackcolor as I enter or get focus ont he cell then change it back to normal when it leaves.

I have not see any code yet that does this.

Thanks for your help
zachvaldezAsked:
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.

RimvisCommented:
Try this:

Option Explicit

Private Sub MSFlexGrid1_RowColChange()
    Dim x As Integer, y As Integer
    Dim i As Integer, j As Integer
    Static bLock As Boolean

    If bLock Then Exit Sub
   
    bLock = True
   
    'remember position
    x = MSFlexGrid1.Col
    y = MSFlexGrid1.Row

    'reset color
    For i = 1 To MSFlexGrid1.Rows - 1
        For j = 1 To MSFlexGrid1.Cols - 1
            MSFlexGrid1.Col = i
            MSFlexGrid1.Row = j
            MSFlexGrid1.CellBackColor = vbWhite
        Next j
    Next i

    'set background color
    MSFlexGrid1.Col = x
    MSFlexGrid1.Row = y
    MSFlexGrid1.CellBackColor = vbRed
   
    bLock = False
   
End Sub
0
zachvaldezAuthor Commented:
Getting i'nvalid column value error'

For i = 1 To MSFlexGrid1.Rows - 1
        For j = 1 To MSFlexGrid1.Cols - 1
            MSFlexGrid1.Col = i  >>>>>> error this point
            MSFlexGrid1.Row = j
            MSFlexGrid1.CellBackColor = vbWhite
        Next j
0
PePiCommented:
MSFlexGrid1.Col = j
MSFlexGrid1.Row = i

Rimvis got it backwards
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

zachvaldezAuthor Commented:
Yes! It changes the color of the cell  when you use the mouse but not when using the enter key..
0
zachvaldezAuthor Commented:
This caused it to flicker the form..
because it is going to every cell. in the grid.. Is it possible to just the single cell...? thanks

  For i = 1 To MSFlexGrid1.Rows - 1
        For j = 1 To MSFlexGrid1.Cols - 1
            MSFlexGrid1.Col = j
            MSFlexGrid1.row = i
            MSFlexGrid1.CellBackColor = vbWhite
      Next j
       
    Next i
0
RimvisCommented:
>> Rimvis got it backwards
Yes, dammit :o)

>>  Is it possible to just the single cell
I don't think it's possible

>>  This caused it to flicker the form
Try this to remove flickering

    MSFlexGrid1.Redraw = False

    'reset color
    For i = 1 To MSFlexGrid1.Rows - 1
        For j = 1 To MSFlexGrid1.Cols - 1
            MSFlexGrid1.Col = j
            MSFlexGrid1.Row = i
            MSFlexGrid1.CellBackColor = vbWhite
        Next j
    Next i

    MSFlexGrid1.Redraw = True
0

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
zachvaldezAuthor Commented:
IT worked!!
0
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 Classic

From novice to tech pro — start learning today.