vb.net中的combobox怎样添加列表项

vb.net中的combobox怎样添加列表项,第1张

dim i as integer

for i=1900 to 2010

combobox1.additem(cstr(i))

next

相关知识:

Cstr函数是将数字转化为字符串

additem命令就是向Combobox中添加列表

添加项: ComboBox1.Items.Add("123")

直接赋值: ComboBox1.Text = "123"

======================

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

For i = 1 To 10

ComboBox1.Items.Add("添加项:" &i)

ComboBox2.Items.Add("添加项:" &i)

Next

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

ComboBox2.SelectedIndex = ComboBox1.SelectedIndex

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11570033.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存