Search code examples
.netwinforms.net-2.0

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?


Solution

  • 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.