vb_net下拉多选 vb下拉选择框
.net中怎么实现下拉框多选,然后获取选中的值
您可以选择使用CheckListBox控件。CheckListBox支持多选。
成都创新互联是一家集网站建设,合浦企业网站建设,合浦品牌网站建设,网站定制,合浦网站建设报价,网络营销,网络优化,合浦网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
由于不清楚您用什么语言,所以我写了VB.net 、C#.net
vb.net Code
' Determine if there are any items checked.
If CheckedListBox1.CheckedItems.Count 0 Then
' If so, loop through all checked items and print results.
Dim x As Integer
Dim s As String = ""
For x = 0 To CheckedListBox1.CheckedItems.Count - 1
s = s "Checked Item " (x + 1).ToString " = " CheckedListBox1.CheckedItems(x).ToString ControlChars.CrLf
Next x
MessageBox.Show(s)
End If
C#.net Code
// Determine if there are any items checked.
if(checkedListBox1.CheckedItems.Count != 0)
{
// If so, loop through all checked items and print results.
string s = "";
for(int x = 0; x = checkedListBox1.CheckedItems.Count - 1 ; x++)
{
s = s + "Checked Item " + (x+1).ToString() + " = " + checkedListBox1.CheckedItems[x].ToString() + "\n";
}
MessageBox.Show (s);
}
vb.net Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim selectstr As String = ""
For i As Integer = 0 To Me.CheckedListBox1.Items.Count - 1
If Me.CheckedListBox1.GetItemChecked(i) Then
selectstr = Me.CheckedListBox1.Items(i).ToString
End If
Next
MsgBox(selectstr)
End Sub
希望能帮到您。
如何在下拉菜单中实现多项选择???(用VB编写)
下拉菜单只能单选,你看它那个样子就知道,任何时间只能看到一项,要多选就用List列表框控件
如何设置VB中下拉菜单有多个选择?
Private Sub Combo1_Change()
q = Combo1.Text
End Sub
Private Sub Command1_Click()
If Combo1.Text = "xsh" And Text1.Text = "123456" Then
Form2.Show
Form1.Hide
ElseIf Combo1.Text = "hhr" And Text1.Text = "12345" Then
Form2.Show
Form1.Hide
ElseIf Combo1.Text = "smt" And Text1.Text = "1234" Then
Form2.Show
Form1.Hide
Else
MsgBox "密码错误或账号错误,请重新输入!"
End If
End Sub
本文名称:vb_net下拉多选 vb下拉选择框
当前地址:http://ybzwz.com/article/dospjch.html