Solved

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

Posted on 2016-09-15
2
71 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 500 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

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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