Hi all,
I am very new to VB. I am using VS2005 vb. I have two textboxes and one grid with two columns
I want to populate the grid values to text box while clicking the exact row?
Is it possible?
can any one give me the solution..?
Thanks
Krishna
Printable View
Hi all,
I am very new to VB. I am using VS2005 vb. I have two textboxes and one grid with two columns
I want to populate the grid values to text box while clicking the exact row?
Is it possible?
can any one give me the solution..?
Thanks
Krishna
Moved to VB.NET
TextBox1.Test = DatagridView1.Item(0,e.RowSelected()).ToString()
TextBox2.Test = DatagridView1.Item(1,e.RowSelected()).ToString()
Mazz1 Thanks for your reply. But I am getting error like
"'RowSelected' is not a member of 'System.Windows.Forms.DataGridView"
Thanks
Krishna
Sorry should be
e.RowIndex()
On the datagrid click or double click event
Please do not bump your thread.
Sorry friend No Luck. Its not working!! :(
In my text box i am getting like "DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=1 }"
-- krishna
This works for me every time:
vb.net Code:
Private Sub dgDances_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgDances.CellDoubleClick If e.RowIndex() < 0 Then Exit Sub End If Me.intDancePK = Integer.Parse(Me.dgDances.Item(0, e.RowIndex()).Value.ToString()) Me.txtDanceName.Text = Me.dgDances.Item(1, e.RowIndex()).Value.ToString() Me.cmdDelete.Enabled = True End Sub
Change .ToString to .Value
Code:TextBox1.Test = DatagridView1.Item(0, e.RowIndex).Value
TextBox2.Test = DatagridView1.Item(1, e.RowIndex).Value
Now its working. I think we have missed the "Value" Word in previous sysntax.
Thnaks Mazz
Krishna
Is this thread still available for posting? I would just like to ask why is it that the datagrid only "reacts" when I click on the second column...