vb_net+下拉多选 vba下拉菜单多选
关于VB.net下拉框的问题
设置一个全局变量:
创新互联公司-专业网站定制、快速模板网站建设、高性价比佳县网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式佳县网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖佳县地区。费用合理售后完善,十载实体公司更值得信赖。
Public item As String
然后在第一个窗口那里取:
item = ComboBox1.SelectedItem.ToString()
然后加到第二个窗口那里:
ComboBox2.DropDownStyle = ComboBoxStyle.DropDownList(这个不可改内容的设定可以在建立ComboBox的时候就设定了)
ComboBox2.Items.Add(item) (加入内容,你或者也可以用别的,比如insert,这个可以加到指定的位置)
ComboBox2.SelectedItem = item (显示那个刚加进来的内容)
这样应该可以了,建议你多看MSDN。
如何设置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+下拉多选 vba下拉菜单多选
文章出自:http://ybzwz.com/article/dohdjjd.html