passing a selected row of DGV to another form (textboxes)

jak

Member
Joined
Feb 21, 2009
Messages
19
Programming Experience
Beginner
Hello EXPERTS,

I hav a datagridview,which looks like this:

ID NAME MARKS GRADE
1 SHEENA 60 C
2 MARIA 80 B
3 ROBBY 65 C
4 TONY 75 B

if i doubleclick a row,lets say second row...then this row value should appear to another form which hav 4 textboxes ( id , name, marks and grade)...i am a beginner so really dont hav any idea....please help me with proper code....thanx in advance...
 
hello evryone...

now i got solution of my problem...suggested by a senior...

Private Sub DataGridView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.DoubleClick
If Not DataGridView.CurrentRow Is Nothing Then
DataGridView1.EndEdit()
Dim frm2 As New PAYMENT
frm2.TextBox1.Text = Investor_transactionDataGridView.CurrentRow.Cells(0).Value.ToString
End If

End Sub

;)
 
Hello Jak. I am totally new to Visual Studio 2008 and programming in general.

I am having a similar issue. I am trying to get data to a RichTextBox1 from a DataGridView. I am trying to use your code and have the data appear in a newly created DataGridView1 box. My code looks like this:
********************************************************
Private Sub VendorsDataGridView_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles VendorsDataGridView.DoubleClick
If Not VendorsDataGridView.CurrentRow Is Nothing Then
DataGridView1.EndEdit()
Dim frm2 As New PAYMENT
frm2.TextBox1.Text = VendorsDataGridView.CurrentRow.Cells(0).Value.ToString
End If
End Sub
********************************************************
The only problem is that in my code the PAYMENT in the statement Dim frm2 As New PAYMENT gives an error," Type PAYMENT is not defined.". Would you happen to know how to define PAYMENT so I could test out your code?
Thanks in advance.
 
payment is the name of his form, so just create a form called payment and it will work.
 
Thanks r3plica. It worked and now I understand more of what the code actually means.
 
Last edited:
Back
Top