【VB开源代码栏目提醒】:以下是网学会员为您推荐的VB开源代码-ComboBox.frm,希望本篇文章对您学习有所帮助。
VERSION 5.00
Begin VB.Form ComboBox
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4425
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4425
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox cmbClient
Height = 1980
Left = 240
Style = 1 'Simple Combo
TabIndex = 5
Top = 360
Width = 2295
End
Begin VB.CommandButton cmdAdd
Caption = "追加(&A)"
Enabled = 0 'False
Height = 375
Left = 2880
TabIndex = 3
Top = 600
Width = 1215
End
Begin VB.CommandButton cmdRemove
Caption = "移去(&R)"
Enabled = 0 'False
Height = 375
Left = 2880
TabIndex = 2
Top = 1080
Width = 1215
End
Begin VB.CommandButton cmdClear
Caption = "清除(&C)"
Height = 375
Left = 2880
TabIndex = 1
Top = 1560
Width = 1215
End
Begin VB.CommandButton cmdClose
Caption = "关闭(&X)"
Height = 375
Left = 2880
TabIndex = 0
Top = 2040
Width = 1215
End
Begin VB.Label lblClients
Caption = "总项目数"
Height = 255
Left = 240
TabIndex = 7
Top = 2640
Width = 855
End
Begin VB.Label lblDisplay
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1080
TabIndex = 6
Top = 2640
Width = 1335
End
Begin VB.Label lblName
Caption = "新项目名"
Height = 375
Left = 240
TabIndex = 4
Top = 120
Width = 1215
End
End
Attribute VB_Name = "ComboBox"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdAdd_Click()
cmbClient.AddItem cmbClient.Text '添加到列表中。
cmbClient.Text = "" '清除文本框。
cmbClient.SetFocus
'显示数目。
lblDisplay.Caption = cmbClient.ListCount
End Sub
Private Sub cmdRemove_Click()
Dim Ind As Integer
Ind = cmbClient.ListIndex '获取索引。
'确保选定列表项目。
If Ind >= 0 Then
'将其从列表中删除。
cmbClient.RemoveItem Ind
'显示数目。
lblDisplay.Caption = cmbClient.ListCount
Else
Beep
End If
'若列表中没有项目,则禁用此按钮。
cmdRemove.Enabled = (cmbClient.ListIndex <> -1)
End Sub
Private Sub cmdClear_Click()
'清空列表框。
cmbClient.Clear
'禁用“删除”按钮。
cmdRemove.Enabled = False
'显示数目。
lblDisplay.Caption = cmbClient.ListCount
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmbClient_Click()
cmdRemove.Enabled = cmbClient.ListIndex <> -1
End Sub
Private Sub cmbClient_Change()
'当 cmbClient 文本框中至少有一个字符时,
'允许“添加”按钮。
cmdAdd.Enabled = (Len(cmbClient.Text) > 0)
End Sub
上一篇:
combinar.frm
下一篇:
还记得,那年的风车吗?