?
Solved

Datagrid

Posted on 2006-11-05
4
Medium Priority
?
175 Views
Last Modified: 2010-04-23
Good evening Experts. I have a column name ID. When I select this row, I want another form to open with that info. How can I accomplish this task?
0
Comment
Question by:VBdotnet2005
  • 3
4 Comments
 
LVL 18

Expert Comment

by:vbturbo
ID: 17879505
   Private Sub DataGrid1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
        Dim DataGrid1 As DataGrid = CType(sender, DataGrid)

        Dim hti As System.Windows.Forms.DataGrid.HitTestInfo

        hti = DataGrid1.HitTest(e.X, e.Y)
        Try
            If hti.Type = DataGrid.HitTestType.Cell Then
 
              MessageBox.Show(dataGrid1(hti.Column).ToString())
              if dataGrid1(hti.Column).ToString() = "ID"  then ' your column name ID

             Dim frm As New Queryform
             frm.ShowDialog()

            End If
 
         Else
 
             If hti.Type = DataGrid.HitTestType.ColumnHeader Then 'assumes datasource is a dataview
 
          MessageBox.Show(CType(DataGrid1.DataSource, DataView).Table.Columns(hti.Column).ToString())
 
     End If

        Catch '//empty catch .. do nothing

        End Try
    End Sub

hope that helps

vbturbo
0
 
LVL 21

Assisted Solution

by:K V
K V earned 800 total points
ID: 17880215
vbturbo is correct !! but for passing infomation to other form,
you need some method that accept that data


Dim frm As Form = new Form
call that public method to pass THAT data..
frm.method_at_NEWFORM(sorted_Data)


public sub method_at_NEWFORM(sorted_data)
{
...
}
0
 
LVL 18

Accepted Solution

by:
vbturbo earned 1200 total points
ID: 17880999
Yeah theGhost_k8

I didn't see he wanted to take the row data into the new opened form....thanks for the wake up call --:')

To VBdotnet2005

You could add a module to your project and declare a public variable

public  ID as integer
public  col1_row_cell_data as integer
public  col2_row_cell_data as integer



  Private Sub DataGrid1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
        Dim DataGrid1 As DataGrid = CType(sender, DataGrid)

        Dim hti As System.Windows.Forms.DataGrid.HitTestInfo

        hti = DataGrid1.HitTest(e.X, e.Y)
        Try
           'Assign the clicked row cell data to the variables for later access when opening the form
            ID = DataGrid1(hti.Row, 0).ToString()
            col1_row_cell_data = DataGrid1(hti.Row, 0).ToString()
            col2_row_cell_data = DataGrid1(hti.Row, 0).ToString()

            If hti.Type = DataGrid.HitTestType.Cell Then
 
              MessageBox.Show(dataGrid1(hti.Column).ToString())
              if dataGrid1(hti.Column).ToString() = "ID"  then ' your column name ID

             Dim frm As New Queryform
             frm.ShowDialog()
             'in the frm that is [open now / going to open]
             'add some labels or what ever
             'lbl0.text=ID
             'lbl1.text=col1_row_cell_data
             'lbl2.text=col2_row_cell_data
            End If
 
         Else
 
             If hti.Type = DataGrid.HitTestType.ColumnHeader Then 'assumes datasource is a dataview
 
          MessageBox.Show(CType(DataGrid1.DataSource, DataView).Table.Columns(hti.Column).ToString())
 
     End If

        Catch '//empty catch .. do nothing

        End Try
    End Sub


0
 
LVL 18

Expert Comment

by:vbturbo
ID: 17881016
woooohhh

alter these
               
            ID = DataGrid1(hti.Row, 0).ToString()
            col1_row_cell_data = DataGrid1(hti.Row, 1).ToString()
            col2_row_cell_data = DataGrid1(hti.Row, 2).ToString()
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month17 days, 4 hours left to enroll

862 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