Reputation: 113
How to get the Combobox selected item which is inside a DataGridView?
Upvotes: 0
Views: 101
Reputation: 61
As others have mentioned in the comments, it would be very useful to provide some sort of code example to explain what you're trying to achieve here, as our solutions may differ depending on the desired outcome, however, the standard procedure for retrieving information from a DataGridView
is:
dataGridView1.SelectedRows[0].Index
Or if you need the indiviual cell, then:
dataGridView1.SelectedCells[0].Index
If you're trying to get the string from the ComboBox
then something along the lines of this may help you:
string SelectedText = dataGridView1.Rows[0].Cells[1].FormattedValue.ToString();
You can then proceed to use the information however you please, for example, if you were trying to get the value instead of the string from the ComboBox
then you would use .Value
instead of using the ToString()
conversions. This is where some information regarding what you're trying to achieve would come in handy.
Hope this helps
Upvotes: 1