vbnet下拉多选 vba下拉菜单多选
如何设置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
.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.net下拉框的问题
设置一个全局变量:
Public item As String
然后在第一个窗口那里取:
item = ComboBox1.SelectedItem.ToString()
然后加到第二个窗口那里:
ComboBox2.DropDownStyle = ComboBoxStyle.DropDownList(这个不可改内容的设定可以在建立ComboBox的时候就设定了)
ComboBox2.Items.Add(item) (加入内容,你或者也可以用别的,比如insert,这个可以加到指定的位置)
ComboBox2.SelectedItem = item (显示那个刚加进来的内容)
这样应该可以了,建议你多看MSDN。
网页标题:vbnet下拉多选 vba下拉菜单多选
文章地址:http://pwwzsj.com/article/dddcgeg.html