Getting values from DataGridView
Hi,
I have a DataGridView on a WinForm that has a column with a combo box in it.
The combo is populated from a datasource and all works great.
My problem is this:
How do I get the value selected (or the text) in the combobox for a specific row when a button is pressed?
any help will be gratefully recieved
thanks
Re: Getting values from DataGridView
I couldn't understand a bit of your question but it looks like you want to get those values from a selected row.
adgda Code:
Textbox1.Text = DataGridView1.SelectedCells(0).Value
0 represents the column.
Re: Getting values from DataGridView
Code:
'Get the index value of the current combo selection in grid
Dim myComboBoxCell As DataGridViewComboBoxCell = DirectCast(dgv.Item(column, row), DataGridViewComboBoxCell)
Dim SelectedIndex As Integer = myComboBoxCell.Items.IndexOf(myComboBoxCell.Value)
'Get text value of combobox
Dim myComboBoxCell As DataGridViewComboBoxCell = DirectCast(dgv.Item(column, row), DataGridViewComboBoxCell)
Dim TypeValue As String = MyComboBoxCell.Value
Re: Getting values from DataGridView
That is exactly what i needed.
Thank you so much.
:)