|
-
Oct 24th, 2007, 10:21 AM
#1
Thread Starter
New Member
Datagrid values to textbox
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
Last edited by csk_abk; Oct 24th, 2007 at 10:36 AM.
-
Oct 24th, 2007, 10:32 AM
#2
Re: Datagrid view to textbox
-
Oct 24th, 2007, 10:47 AM
#3
Re: Datagrid values to textbox
TextBox1.Test = DatagridView1.Item(0,e.RowSelected()).ToString()
TextBox2.Test = DatagridView1.Item(1,e.RowSelected()).ToString()
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Oct 24th, 2007, 10:50 AM
#4
Thread Starter
New Member
Re: Datagrid values to textbox
Mazz1 Thanks for your reply. But I am getting error like
"'RowSelected' is not a member of 'System.Windows.Forms.DataGridView"
Thanks
Krishna
-
Oct 24th, 2007, 10:53 AM
#5
Re: Datagrid values to textbox
Sorry should be
e.RowIndex()
On the datagrid click or double click event
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Oct 24th, 2007, 10:54 AM
#6
Re: Datagrid values to textbox
Please do not bump your thread.
-
Oct 24th, 2007, 11:01 AM
#7
Thread Starter
New Member
Re: Datagrid values to textbox
Sorry friend No Luck. Its not working!! 
In my text box i am getting like "DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=1 }"
-- krishna
-
Oct 24th, 2007, 11:06 AM
#8
Re: Datagrid values to textbox
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
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Oct 24th, 2007, 11:10 AM
#9
Member
Re: Datagrid values to textbox
Change .ToString to .Value
Code:
TextBox1.Test = DatagridView1.Item(0, e.RowIndex).Value
TextBox2.Test = DatagridView1.Item(1, e.RowIndex).Value
-
Oct 24th, 2007, 11:12 AM
#10
Thread Starter
New Member
Re: Datagrid values to textbox
Now its working. I think we have missed the "Value" Word in previous sysntax.
Thnaks Mazz
Krishna
-
Jan 16th, 2010, 11:01 AM
#11
Addicted Member
Re: Datagrid values to textbox
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...
====================
ほんとにどもありがとう!
Rie Ishida
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|