I am newbie in VB.Net..

Please help me in this

how can we view the selected row's data from datagrid in textboxes in vb.net 2003?

5 Years
Discussion Span
Last Post by M.Waqas Aslam

hello kurakar ! ,
basically i m using vs2008 ,in 2008 i m using bindingsource for this purpose , i bind my form controls with same bindingsource which is used by me to populate the datagrid ,
by doing all this when ever i click on my grid row same records are shown by my textboxes , sorry for my bad english

Hope this will help u

M.Waqas Aslam


hello kurakar !
there are two ways to perform ur required operation.
1- use bindingsource
2-manualy show records in textboxes.
now here is the code to bind the textbox.

'first assign the same datasource to bindingsource which is used to assign the datasource to gridview.
bindingsource1.datasource = 'write ur datasource.
'after this now bind ur textboxes with this bindingsource.
textbox1.databinding.add("text",bindingsource1,"__your field name___",false)'u have to write checked for chkbx , and selected for the raio button in the place of "text" and when u bind picture box then change the false to true ,

by using above code ur controls bind with ur datasource , now if u select any row the result will show in textboxes ,
now here is an other method for doing same thing.

sub GridValues()
'now u have to manualy assign the values to the textboxes
textbox1.text = datagridview1.item("__ur column name__",datagridview1.currentrow.index).value.tostring 'in the place of column name u can also place the column index .

after making this sub , now call it on the keypress event of the grid and double or single click event of the grid .
Hope this will helps u
M.Waqas Aslam

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.