How do I change the width of the combobox button?

Viewed 2993

My combobox allows typing into the text portion so the only way to get the dropdown list is to click the button. However, since this will be used on touchscreen devices, it is hard to click it when it is this 'thin'.

Is there any way to increase the width of the combobox button?

enter image description here

2 Answers

One alternative to resizing the button would be to set the DroppedDown property to true inside the Click event. This will show the drop down list when the user clicks inside the edit area of the ComboBox, effectively extending the button area to the whole control:

private void comboBox1_Click(object sender, EventArgs e)
{
    comboBox1.DroppedDown = true;
}

If you want to customize dropdown button (the size of the arrow and the size of the button are completely in our control), there is a class called Combo​Box​Renderer.

Here you have complete example.

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.comboboxrenderer?view=netframework-4.7.2

It is supported from .Net2.0.

You should create a custom ComboBox control and call DrawDropDownButton of the comboboxrenderer in the paint event.

In the above link(example) arrowSize and arrowRectangle are two variables which helps in deciding your dropdown button size, along with below static function (of ComboBoxRenderer) call in overridden paint event.

ComboBoxRenderer.DrawDropDownButton(e.Graphics, arrowRectangle,arrowState);
Related