vb.net - ComboBox ItemList SelectedValue -
vb.net (2010)
i'm trying create combobox value , display items. here relevant bits of code. tried use datatable same result:
private sub form1_load(sender object, e system.eventargs) handles me.load try cmbfromgroup.items.clear() itemlist.clear() item = new selectionitem(keyvalue, displayvalue) 'link combobox , item itemlist.add(item) cmbfromgroup.datasource = itemlist cmbfromgroup.displaymember = "display" cmbfromgroup.valuemember = "key" catch ex exception stop end try end sub private sub cmbfromgroup_selectedindexchanged(sender system.object, e system.eventargs) handles cmbfromgroup.selectedindexchanged try cmbfrommp3.items.clear() dim x string = cmbfromgroup.selectedvalue ' <snip> cmbfrommp3.selectedindex = 0 catch ex exception stop end try end sub public interface iselectionitem property key string property display string end interface public class selectionitem implements iselectionitem public sub new(byval vkey string, byval vdisplay string) _key = vkey _display = vdisplay end sub public property key string implements iselectionitem.key public property display string implements iselectionitem.display end class
the problem i'm having cmbfromgroup.selectedvalue doesn't contain value of selected item.
what i'm getting (from watch) cmbfromgroup.selectedvalue {player.selectionitem} object
the options cmbfromgroup.selectedvalue equals,gethashcode, gettype, referenceequals , tostring, none of give me valuemember i'm expecting.
how valuemember selected item?
use .text
on combo:
dim x string = cmbfromgroup.text
Comments
Post a Comment