vb6中怎样实现可多选的下拉框?(像是combobox和listbox的结合体)
combobox能下拉弹出,但不能复选;listbox能复选但不能弹出。有无能实现弹出式下拉复选框的空间?
如附图这种: vb6?复选?下拉框
[解决办法]
C1Studio、Xceed等第三方控件包中有现成的
[解决办法]
自己用 TextBox, CommandBox 和 ListBox(Style = 1)控件“组装”一个:
Option Explicit
Private Sub Command1_Click()
Dim strTmp As String, i As Integer
If List1.Visible Then
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then strTmp = strTmp & IIf(strTmp > "", ",", "") & List1.List(i)
Next i
If InStr(strTmp, ",") Then
Text1 = "(" & strTmp & ")"
Else
Text1 = strTmp
End If
Text1.SetFocus
List1.Visible = False
Command1.Caption = 6
Else
List1.Visible = True
List1.SetFocus
Command1.Caption = 5
End If
End Sub
Private Sub Form_Load()
List1.AddItem 1
List1.AddItem 2
List1.Top = Text1.Top + Text1.Height + 10
List1.Visible = False
Command1.Height = Text1.Height - 60
Command1.Width = Command1.Height
Command1.Top = Text1.Top + 30
Command1.Left = Text1.Left + Text1.Width - Command1.Width - 30
Command1.Caption = "6"
Command1.Font = "Webdings"
Command1.Font.Size = 9
Text1 = ""
End Sub