2012-04-16 215 views
1

我已經看到comboBoxes看起來像一個小箭頭在底部右邊的按鈕,表明它是一個精靈下拉菜單,有幾個選項。這是如何完成的?有什麼我可以改變的組合框的屬性?謝謝!ComboBox就像一個按鈕?

編輯:我使用Windows窗體在Visual Studio 2010

+0

Windows窗體或WPF? – Tigran 2012-04-16 09:31:20

+1

對於WinForms,沒有什麼開箱即用的。您可以在Infragistics,DevExpress,Telerik和其他人提供的控件套件中找到這種控件。 (例如,Infragistics有一個控件類名稱UltraDropDownButton) – Steve 2012-04-16 09:33:46

回答

0

ComboBox.DropDownStyle = ComboBoxStyle.DropDownList試試這個

0
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 
this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup; 
this.comboBox1.FormattingEnabled = true; 
this.comboBox1.Items.AddRange(new object[] 
{ 
    "Item 1", 
    "Item 2", 
    "Item 3", 
    "Item 4", 
    "Item 5" 
}); 
+0

謝謝,但這並沒有工作 – 2012-04-16 10:01:23

0

我知道OP被問及SplitButton爲的WinForms,但WinForms的沒有被提及在帖子的標題中,所以尋找分離按鈕以供其他技術使用的人可能會在這裏結束。

如果您正在尋找WPF中的分割按鈕,那麼您可以在WPF Extended Toolkit中使用the SplitButton provided free

這是我在WPF應用程序中如何使用它的一個小屏幕截圖。

enter image description here