?
Solved

DataGrid

Posted on 2003-02-25
5
Medium Priority
?
211 Views
Last Modified: 2010-05-01
I am sick of looking on MSDN ...

Can someone tell me how I can return the Value in the first Column of the Selected Row of a Datagrid.

The value always seems to be one click behind.

Thanks
Wayne
0
Comment
Question by:wlawson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 2

Expert Comment

by:IeuanJ
ID: 8023621
Instead of using the onClick event use the onRowChange event.  Click is an object level event not a data level one.

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    MsgBox DataGrid1.Text

End Sub
0
 
LVL 1

Expert Comment

by:xThorx
ID: 8023636
To retreive the value of a colum X of a slected row:

grid.col=x-1
value_of_the_element=grid.text

Hope that's what your looking for
0
 
LVL 2

Accepted Solution

by:
IeuanJ earned 150 total points
ID: 8023651
Apologies I forgot about the first column bit.

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    Dim oldCol As Integer

    oldCol = DataGrid1.Col
    DataGrid1.Col = 0
    MsgBox DataGrid1.Text
    DataGrid1.Col = oldCol
End Sub
0
 

Author Comment

by:wlawson
ID: 8029610
Thanks,

I actually found that if I ignored the first click, it moved the pointer to the right Row and then the second click found the correct value of Column(0) in the selected Row.

But you can have the points anyway.

Probably could have used the DBLCLICK event for the same affect.
0
 
LVL 2

Expert Comment

by:IeuanJ
ID: 8031895
both the click and double click event work on the object, they will process the routine BEFORE moving the focus to the new cell, the whole point of RowColChange is that it get processed only when the focus has changed toa  new cell.  The work around you have is neither efficient or good practise, I strongly suggest you change.

Also why a B grade here, my answer did exactly as you asked !!!!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question