Solved

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

Posted on 2016-09-15
2
43 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
2 Comments
 
LVL 29

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XML to SQL Table using c# 5 46
visual Basic Net vs c# net 8 56
bulid json format 3 19
Get list of word ducuments in a folder 10 17
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now