?
Solved

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

Posted on 2016-09-15
2
Medium Priority
?
75 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

764 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