?
Solved

Datagrid Doubleclick prblem

Posted on 2005-05-05
4
Medium Priority
?
346 Views
Last Modified: 2010-04-23
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

0
Comment
Question by:chrisryhal
  • 2
4 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 400 total points
ID: 13941080
0
 
LVL 14

Accepted Solution

by:
amyhxu earned 1600 total points
ID: 13942737
What is your datagrid's datasource? I'm guessing a dataview which uses a row filter to get the rows you want according to ToolID. And that would explain why you got Description = MachineShop.

Suppose I'm guessing right, the solution could be:

    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(DocumentDatagrid.DataSource, DataView)(hti.Row)("Description").ToString()
        End If
End Sub
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 13944706
amyhxu:   YES!!!!!!  Thank you so much!!!
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 13944716
emoreau:  That was a great website to bookmark too.  I will give you some points too.  I learned a lot from that site.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

809 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