Link to home
Start Free TrialLog in
Avatar of chrisryhal
chrisryhal

asked on

Datagrid Doubleclick prblem

I have a datagrid that is displaying information based on a ToolID.  A doubleclick feature is on the datagrid, to fill a textbox on the form with data from the column "Description".   The function is "kinda" working, however, the doublecllick feature is not displaying the correct information.  Example table view direct from SQL:

ID    ToolID    Description
====================
1      10001      MachineShop
2      10001      MachineShop
3      10009         Shipping
4      10009         Shipping
5      25847        Inspection  

Now, on the actual Windows Form, it display's like so, because in this case ToolID = 25847

ID    ToolID    Description
====================
5      25847        Inspection  

However, when I doubleclick the row, the value I get is Description = MachineShop.  


=================CODE===================

    Private Sub DocumentDataGrid_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DocumentDatagrid.DoubleClick
        Dim pt As System.Drawing.Point = DocumentDatagrid.PointToClient(Cursor.Position)
        Dim hti As DataGrid.HitTestInfo = DocumentDatagrid.HitTest(pt)
        If hti.Type = DataGrid.HitTestType.RowHeader Then
            txtDescription.Text = CType(DocumentData.Tables(0).DefaultView.Item(hti.Row).Item("Description"), String)
        End If
End Sub

SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada 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
ASKER CERTIFIED SOLUTION
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
Avatar of chrisryhal
chrisryhal

ASKER

amyhxu:   YES!!!!!!  Thank you so much!!!
emoreau:  That was a great website to bookmark too.  I will give you some points too.  I learned a lot from that site.