Share via


how to get column value from data table to textbox in vb 2010?

Question

Monday, May 14, 2012 9:59 AM

hi all

how to get selected row column value from data table to textbox in vb 2010?

with regards

All replies (5)

Tuesday, May 15, 2012 12:22 PM ✅Answered

See the below link:

How to: Get the Selected Cells, Rows, and Columns in the Windows Forms DataGridView Control

Paul ~~~~ Microsoft MVP (Visual Basic)


Tuesday, May 15, 2012 9:30 AM

Hi Mind-Reader,

It’s nice to see you here.

In fact, I’m a little confused to your description. Data table doesn’t have a GUI; I’m not sure how you “select”its cell.  It can be a data source of DGV, list box, etc. Whatever, if you get the row and column index of data table, you can use code like this to get its value and set to textbox.

Dim dt As New DataTable
….
TextBox1.Text = dt.Rows(RowIndex)(ColumnIndex).ToString

If I misunderstood anything, please feel free and let me know.

Best regards,

Shanks Zen
MSDN Community Support | Feedback to us


Tuesday, May 15, 2012 10:02 AM

Hello Shanks Zen

thanks for your fast response

have a DataGridView binding with Students table

have fields in Students table

StuentID

StudentName

Students table's contents display in DataGridView it's ok

Now i want StudentName Value to TextBox1 Means ( Student's Name )

selected row from DataGridView

how can?

with regards


Sunday, April 23, 2017 2:23 PM

Thanx. It's working fine.


Sunday, April 23, 2017 3:01 PM

Thanx. It's working fine.

Hi

Took 5 years to get it to work!

Regards Les, Livingston, Scotland