Brendan Gooden
Brendan Gooden

Reputation: 1551

C# ComboBox to activate dropdown list when clicking on dropdown text

I've got a Windows Forms application written in Visual Studio 2015. Its a simple form with a couple of dropdown menus (combo boxes) and I'm wanting the dropdown list to pull down when the user clicks anywhere in the combobox frame, not only when they click on the arrow right hand side.

enter image description here

The combobox in my code is as follows:

private System.Windows.Forms.ComboBox cbxMake;

Upvotes: 4

Views: 14378

Answers (2)

Grant Winney
Grant Winney

Reputation: 66439

If you want to allow the user to enter text in the TextBox portion of the ComboBox, but also display the drop-down list when the user clicks the TextBox, subscribe to the MouseClick event:

private void cbxMake_MouseClick(object sender, MouseEventArgs e)
{
    cbxMake.DroppedDown = true;
}

No matter where the user clicks on the control, whether it's the "down" triangle or the TextBox, the drop-down will be displayed.

Upvotes: 7

Brendan Gooden
Brendan Gooden

Reputation: 1551

I found the solution to be changing the DropDownStyle in the Appearance properties from DropDown to DropdownList

This did exactly what I was after - changing it from this

enter image description here

To this

enter image description here

Which enabled me to select the dropdown list by clicking anywhere in the box, rather than just on the arrow on the far right of the combobox.

Upvotes: 10

Related Questions