Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ToolStripSplitButton does not close drop-down list when the arrow is clicked

Posted on 2016-09-15
2
Medium Priority
?
88 Views
Last Modified: 2016-09-15
Hi experts
I wonder how I could get a ToolStripSplitButton to behave the same as a Combobox when the arrow is clicked.

With a Combobox, click the arrow will open its drop-down list. Click it again will close the drop-down list.
With a ToolStripSplitButton. click the arrow will open its drop-down list (which is expected), but clicking the arrow again, the ToolStripSplitButton doesn't close the drop-down list (as in a combobox).

I am using VS2008, Winform, C#.

Thanks in advance
Dominic
0
Comment
Question by:dominicwong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 2000 total points
ID: 41800879
I believe this control was created with this behavior for a reason. And myself I don't like to change behavior for standard controls. However, you may try the following code. Honestly, not sure how robust it is :).

You may need to add event handlers to your project...

namespace ToolStripTest
{
    public partial class Form1 : Form
    {

        private bool isClickedToOpen = false;
        public Form1()
        {
            InitializeComponent();
        }

        private void toolStripSplitButton1_Click(object sender, EventArgs e)
        {
            if (isClickedToOpen)
            {
                toolStripSplitButton1.HideDropDown();
            }

            isClickedToOpen  = !isClickedToOpen ;
            System.Diagnostics.Debug.WriteLine("Click");
        }

        private void toolStripSplitButton1_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            isClickedToOpen = !isClickedToOpen;
        }

        private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e)
        {
            isClickedToOpen = false;
            System.Diagnostics.Debug.WriteLine("ButtonClick");
        }
    }
}[/code]
0
 

Author Closing Comment

by:dominicwong
ID: 41800938
Thanks anarki_jimbel.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question