📄 frmcombo.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Fig. 10.17: ComboBox"
ClientHeight = 2220
ClientLeft = 2535
ClientTop = 2220
ClientWidth = 4140
LinkTopic = "Form1"
ScaleHeight = 2220
ScaleWidth = 4140
Begin VB.CommandButton cmdClear
Caption = "Clear"
Height = 495
Left = 2790
TabIndex = 6
Top = 705
Width = 1215
End
Begin VB.CommandButton cmdRemove
Caption = "Remove"
Height = 495
Left = 2790
TabIndex = 3
Top = 150
Width = 1215
End
Begin VB.TextBox txtInput
Height = 360
Left = 105
TabIndex = 0
Top = 1320
Width = 2340
End
Begin VB.CommandButton cmdInput
Caption = "Add"
Height = 495
Left = 2790
TabIndex = 1
Top = 1230
Width = 1215
End
Begin VB.ComboBox cboCombo
Height = 315
IntegralHeight = 0 'False
Left = 90
TabIndex = 2
Top = 150
Width = 2385
End
Begin VB.Label lblPrompt
Caption = "ComboBox item:"
Height = 240
Left = 135
TabIndex = 5
Top = 1050
Width = 2325
End
Begin VB.Label lblStats
BorderStyle = 1 'Fixed Single
Height = 270
Left = 75
TabIndex = 4
Top = 1845
Width = 3915
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 10.17
' Demonstrating the ComboBox control.
Option Explicit ' General declaration
Private Sub cmdInput_Click()
' Add item to cboCombo drop-down list
Call cboCombo.AddItem(txtInput.Text)
' Display input in cboCombo's text area
cboCombo.Text = txtInput.Text
Call UpdateLabel ' Display stats
txtInput.Text = "" ' Clear user input
End Sub
Private Sub UpdateLabel() ' Programmer defined procedure
lblStats.Caption = "ListCount: " & cboCombo.ListCount & _
" ListIndex: " & cboCombo.ListIndex & _
" New Index: " & cboCombo.NewIndex
End Sub
Private Sub cboCombo_LostFocus()
' When cboCombo loses focus call updateLabel
Call UpdateLabel
End Sub
Private Sub cmdClear_Click()
cboCombo.Clear ' Clear all items
Call UpdateLabel ' Display stats
End Sub
Private Sub cmdRemove_Click()
' Remove item from cboCombo
Call cboCombo.RemoveItem(cboCombo.ListIndex)
' Display cboCombo item 0
cboCombo.Text = cboCombo.List(0)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -