
1、窗体设计时
在属性窗口中找到List属性,直接添加即可,如下图:
2、通过代码添加
Combo1.AddItem "内容"
dim jfor j=0 to combox.listcount-1
if combo1.list(i)=你要对比的字符串 then
msgbox("存在相同项目")
end if
next j
就是用list属性,后面的括号是数字,就是combo控件中的项目号,
明白这个属性了,你就知道咋做了。
首先定义一个公共的方法public void BindComBox(ComboBox comBox,DataSet ds)
{
comBox.DataSource=ds.Tables[0].DefaultView
comBox.DisplayMember = "Type"
comBox.ValueMember = "Type"
}
然后在页面上调用
Page_Load()
{
Maticsoft.BLL.T_Banci banci = new Maticsoft.BLL.T_Banci()
DataSet ds = banci.GetList("")
BindComBox(comBox1,ds)
BindComBox(comBox2,ds)
BindComBox(comBox3,ds)
BindComBox(comBox4,ds)
BindComBox(comBox5,ds)
BindComBox(comBox6,ds)..................................
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)