How would you be able to Capture the Value of a Cell when the User Selects a Row?

Recommended Answers

All 7 Replies

I guess that you are looking for a particular column in your datagridview.

DataGridView1.Item(0, DataGridView1.SelectedRows.Item(0).Index).Value

@Joshua Kidd : Not getting you.....

I have A Datagrid view. And I want the User to be able to select a Row, but when They Select that row is Gets the Value of the 2nd Cell in the 2nd Column and puts it in a TextBox.

textbox.text = DataGridView1.Item(1, DataGridView1.SelectedRows.Item(0).Index).Value

Make sure you've disabled multiple rows selection or that you've tested that the results meet your requirements.

or you can try this:

texbox1.Text =  DataGridView1.SelectedRows(0).Cells(1).Value.ToString()
textbox.text = DataGridView1.Item(1, DataGridView1.SelectedRows.Item(0).Index).Value

Make sure you've disabled multiple rows selection or that you've tested that the results meet your requirements.

Thanks very Much. This Worked ;)

Then please mark this thread as solved.
Thx.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.