Datagrid Row-property

I´m using a Datagrid that has 8 columns. When the user clicks in a cell I would like to determine which row and column he clicked. This because if the user clicks in column 5 a window should appear otherwise should the row get highlighted (selected).

When I´m using the Col- and Row-properties of the Datagrid it is one step behind. For example: I click in column 4 and row 2, the col and row properties show the value -1. Next time I click column 5 and row 3, now the properties show the value 4 and 2 (as it should on the first click):

Therefore I have these questions:
1) How do I solve this matter and determining the right column and row?

2) How do I highlight a single row when the user clicks a cell?

Andreas
polksolkAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

TimCotteeHead of Software ServicesCommented:
This code should provide what you want.

Private Sub grdDataGrid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    If grdDataGrid.Col = 4 Then
        MsgBox ("In Col 5")
    Else
        If grdDataGrid.SelBookmarks.Count > 0 Then
            For Each bmkBookmark In grdDataGrid.SelBookmarks
                bmkBookmark.Remove (0)
            Next
        End If
        grdDataGrid.SelBookmarks.Add (grdDataGrid.RowBookmark(grdDataGrid.Row))
    End If
End Sub
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
polksolkAuthor Commented:
Thanks!
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.