否AFAIK,你不能這樣做。以下是兩種選擇。隨你挑:)
替代1
取消的那一刻用戶選擇相關的頭。例如
Private Sub UserForm_Initialize()
ComboBox1.Style = fmStyleDropDownList
ComboBox1.AddItem "--- Main Courses ---"
ComboBox1.AddItem "Roast Beef with Mashed Potato"
ComboBox1.AddItem "Spicy Spareribs"
ComboBox1.AddItem "--- Desserts ---"
ComboBox1.AddItem "Mango Float"
ComboBox1.AddItem "Brownies"
End Sub
Private Sub ComboBox1_Click()
Select Case ComboBox1.Value
Case "--- Main Courses ---", "--- Desserts ---"
ComboBox1.Value = ""
End Select
End Sub
替代2個
使用兩個組合框。一個用於標題,另一個用於不同的菜單項目。根據第一個組合框的選擇簡單地填充第二個組合框。例如
Private Sub UserForm_Initialize()
ComboBox1.Style = fmStyleDropDownList
ComboBox2.Style = fmStyleDropDownList
ComboBox1.AddItem "--- Main Courses ---"
ComboBox1.AddItem "--- Desserts ---"
End Sub
Private Sub ComboBox1_Click()
ComboBox2.Clear
Select Case ComboBox1.Value
Case "--- Main Courses ---"
ComboBox2.AddItem "Roast Beef with Mashed Potato"
ComboBox2.AddItem "Spicy Spareribs"
Case "--- Desserts ---"
ComboBox2.AddItem "Mango Float"
ComboBox2.AddItem "Brownies"
End Select
End Sub
同樣爲了更安全一方,請使用ComboBox1_Change
事件。
感謝您的支持! :) – dunkelme 2014-10-20 16:53:42