when DataGridView has a combobox column, how can I get the text it displays as oppose to the value it represents? When I do DGV.Item("cbo",i).Va开发者_JAVA技巧lue
I get the value but it won't take DGV.Item("cbo",i).Text
. I trying Ctype(DGV.Item("cbo",i),ComboBox).Text
and this does not work either.
Try
DGV.item("cbo",i).DisplayMember
Umm are you talking about Win Forms?
If so, Value
is the property you want, and is what is to be displayed on the screen and held behind the scenes.
If you want something different not shown to the user, I've often used the property Tag
for that.
I found this, and the answers didn't work for me. In case someone else finds this, here is what I did.
dgv.rows(i).Cells(cboname.index).EditedFormattedValue
Hope if someone finds this through Google it will help them.
Dim dgvcmbcell As DataGridViewComboBoxCell = DgvItemsUnits.Item("UNIT_SER", 0)
Dim SelectedText As String = dgvcmbcell.EditedFormattedValue.ToString()
精彩评论