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下拉菜单多选
网页地址:https://www.cdcxhl.com/article46/dddcgeg.html

成都网站建设公司_创新互联,为您提供网站导航电子商务外贸网站建设网站策划动态网站网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都定制网站建设