Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What control is this? ("Open" Button with Drop Down)

The Open button on the open file dialog used in certain windows applications includes a dropdown arrow with a list of additional options — namely Open With...

Open File Dialog

I haven't seen this in every Windows application, so you may have to try a few to get it, but SQL Server Management Studio and Visual Studio 2017 will both show the button that way if you go to the menu and choose File->Open->File...

I want to use a button like this with a built-in list in one of my applications, but I can't find the control they're using anywhere in Visual Studio. I should clarify that I'm looking for that specific button, not the entire dialog. Any thoughts?

like image 942
Joel Coehoorn Avatar asked Aug 27 '08 20:08

Joel Coehoorn


People also ask

What does switch windows drop-down button do?

The Drop-Down Button consists of a button that when clicked displays a drop-down list of mutually exclusive items.

What is a drop button?

A drop-down button is a special type of button that displays a menu. A menu can contain one or more buttons, and these can themselves be drop-down buttons. This lets you create cascading menus.


1 Answers

I used the draggable search in Spy++ (installed with VS) to look at the split open button on the file-open dialog of VS.

This revealed that it's an ordinary windows button with a style which includes BS_DEFSPLITBUTTON. That's a magic keyword which gets you to some interesting places, including

http://www.codeplex.com/windowsformsaero/SourceControl/FileView.aspx?itemId=212902&changeSetId=9930

and here

http://msdn.microsoft.com/en-us/library/bb775949.aspx#using_splits

Hope this helps you.

EDIT:

I've actually just tried that code from CodePlex and it does create a split button - but you do have to make sure you've set the button's FlatStyle to 'System' rather than 'Standard' which is the default. I've not bothered to hook-up the event handling stuff for the drop-down, but that's covered in the MSDN link, I think.

Of course, this is Vista-only (but doesn't need Aero enabled, despite the name on codeplex) - if you need earlier OS support, you'll be back to drawing it yourself.

like image 73
Will Dean Avatar answered Sep 21 '22 15:09

Will Dean