怎么把Combobox的下拉列表显示成Checkbox

 我来答
匿名用户
2016-09-01
展开全部
' 在窗体中加入一个CheckedListBox,和一个ComboBox
Public Class Form1

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With Me.CheckedListBox1
.Visible = False
.Items.Add( "Check it out! ")
.Items.Add( "How about this ")
.Items.Add( "Tis good too! ")
.Height = Me.CheckedListBox1.Items.Count * 18
.CheckOnClick = True
End With
Me.Timer1.Enabled = False
Me.Timer1.Interval = 10
End Sub

Private Sub ComboBox1_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.DropDown
Me.ComboBox1.DropDownHeight = 1
With Me.CheckedListBox1
.Top = Me.ComboBox1.Top + Me.ComboBox1.Height
.Left = Me.ComboBox1.Left
.Width = Me.ComboBox1.Width
.Visible = True
End With
End Sub

Private Sub CheckedListBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckedListBox1.MouseLeave
Me.CheckedListBox1.Visible = False
Me.ComboBox1.Text = " "
For i As Int32 = 0 To Me.CheckedListBox1.CheckedItems.Count - 1
Me.ComboBox1.Text &= Me.CheckedListBox1.CheckedItems(i).ToString & ", "
Next
Me.ComboBox1.Text = Me.ComboBox1.Text.TrimEnd( ", ")
End Sub
End Class
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式