您的位置:程序门 -> .net技术 -> vb.net



关于combobox获取值问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于combobox获取值问题
发表于:2007-08-28 11:01:42 楼主
winform中,combobox绑定到dataview中的一列(绑定没问题),在程序中想通过选择的项获得当前项的值。

dim   id   as   integer
...  
id=cint(me.combobox1.selectedvalue.tostring)  
(错误提示:从字符串“system.data.datarowview”到类型“integer”的转换无效)
尝试了定义一个datarowview的对象来获取值,再把datarowview对象中的列的值提取出来,但也出现错误:
                dim   objdatarowview   as   datarowview
                objdatarowview   =   ctype(me.combobox1.selectedvalue,   datarowview)(错误提示:无法将类型为“system.int32”的对象强制转换为类型“system.data.datarowview”)

//调试时用一个label显示值:   label1.text=me.combox1.selectedvalue.tostring能正确得到combobox1的valuemember值。

请问如何才能引用到combobox中的valuemember值?
发表于:2007-08-28 11:10:021楼 得分:0
使用:  
            dim   objdatarowview   as   datarowview
                objdatarowview   =   ctype(me.combobox1.selecteditem,   datarowview)
发表于:2007-08-28 13:16:312楼 得分:0
谢谢linlin1972(林林)


快速检索

最新资讯
热门点击