ToolBar 控件;Style = tbrButtonDropDownDropdownStyle = tbrDropDownMenu(彈出菜單模式)Menu 編輯器定義的菜單(如 mnuComboPopup),項目可包含圖標、單選/複選框、分隔線;ButtonClick 事件中:Private Sub Toolbar1_ButtonClick(ByVal Button As Button)
If Button.Key = "myComboBtn" Then
PopupMenu mnuComboPopup, vbPopupMenuLeftAlign
End If
End Sub
Click 事件中寫入業務邏輯,並可通過 Button.Caption 或 Button.ToolTipText 反饋選中值。若必須用原生 ComboBox:
Style = 2 - Dropdown List(僅允許選擇,禁止編輯);GotFocus 時將 Width 設置為僅顯示下拉箭頭寬度,失去焦點恢復——但體驗極差,強烈不推薦。第三方 ActiveBar (原 BCGControlBar VB 版) 原生支持在 ToolBar 上嵌入任意 ActiveX 控件(含真正的 ComboBox、DateTimePicker、ColorPicker),樣式完美模仿 Office 2003/2007 Ribbon,適合商業級項目。
下載地址:CSDN 下載
「ToolBar DropDown 按鈕 + PopupMenu」是零成本、原生穩定、易維護的最佳實踐;追求極致 UI 一致性則投入 ActiveBar。