How to change dropdown button in a ComboBox
control (C#, Windows Forms)? I have a custom button, and I want to use it in the ComboBox
instead of the default dropdown button.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I think Hans Passant solution is the way...
From here:
You can create a UserControl, drag a ComboBox and a Button onto it, make the Button right over the ComboBox's arrow button to make the arrow button invisible, handle the Button's Paint event to draw an arrow on it, this can be done by calling ComboBoxRenderer.DrawDropDownButton() method (Notice: this method has a limit, it needs the visual style being enabled on the OS) or by drawing an icon on it, or just drawing a small triangle on it. Then handle the Click event of the button to show the ComboBox's DropDown, this can be done by something like this
private void button1_Click(object sender, EventArgs e) { this.comboBox1.DroppedDown = true; }