Results 1 to 5 of 5

Thread: DropDownButton outside of a Toolbar

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    5

    DropDownButton outside of a Toolbar

    Is it possible in .NET to easily make a drop down button control, such as you might find in a toolbar, but in another location on a form?

    To be more precise, what I want is a button with two functions, depending on which part is clicked. The greatest area is on the left side, represented by the icon for the button, and has the default action. A small sliver on the right side of the button is represented by a drop down arrow, and presents a menu when clicked.

    This is very intuitive behaviour, and I really want to use it in an application, but the only control I can find with this behaviour is the toolbarbutton control
    Attached Images Attached Images   

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: DropDownButton outside of a Toolbar

    Welcome to the Forums.

    Yes, you can display the popup dropdown menu of a toolbar button manually via code in any location of the form.

    I have some code, hold on...
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: DropDownButton outside of a Toolbar

    I found it. It shouws how to call the drowdown menu from a toolbar button click and position it. Just change the X/Y location to position the menu where you want.

    http://www.vbforums.com/showpost.php...18&postcount=8

    Moved from .NET Architecture and Design
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DropDownButton outside of a Toolbar

    I think the point here is that segfault doesn't want to use a Toolbar, but rather just a regular Button on a form with the same behaviour as a ToolBarButton with a drop-down menu. You can easily display a drop-down menu when a Button is clicked by creating a ContextMenu and calling its Show method from the Button's Click event handler. You pass the Button as the first argument and the relative location as the second. Given that you want to have a two part button, I'd say that your best bet would be to create a UserControl that contained two Buttons adjacent to each other and a ContextMenu. You may have to fiddle with things a bit to make it look like two parts of the same button rather than two seperate buttons. There is plenty of information in the help or at MSDN on-line about creating UserControls.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    5

    Re: DropDownButton outside of a Toolbar

    Thanks for the responses, guys. jmcilhinney hit the nail on the head. I haven't educated myself on .NET user controls, but as long as it's well documented, i'll be ok.

    On a different subject, since I'm new here, will someone explain why this thread was not appropriate for the .NET Architecture and Design forum? I'm actually developing in C#, but the prebuilt controls are language independant, right?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width