开发者

DataGridView and Combobox Column?

开发者 https://www.devze.com 2022-12-11 07:03 出处:网络
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

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消