Click here to Skip to main content
11,797,944 members (79,106 online)
Click here to Skip to main content

Tagged as

Creating a simple ButtonDropdown Control

, 25 Sep 2013 CPOL 20.4K 609 22
Rate this:
Please Sign up or sign in to vote.
How to create a simple ButtonDropdown control


This post helps to create a ButtonDropDown in Windows Form (I was not able to find a control in Visual Studio for my requirement, so I made one and I’m not sure whether there is one already). For this, I’m using a combination of Button control and ContextMenuStrip control.


The arrow in the button is an image with middle-right aligned.

  1. Initialize a ContextMenuStrip with the required MenuItems
  2. Register the click events of ContextMenuStripMenuItems
  3. Pop out the context menu on Button click with the given x, y axis (w.r.t to the button), y axis value should be the height of the button:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ButtonDropDownTest
    public partial class Form1 : Form
        private ContextMenuStrip _contextMenuAutoFill;

        public Form1()

        private void CreateContextMenuStrip()
            _contextMenuAutoFill = new ContextMenuStrip();
            _contextMenuAutoFill.Items.Add("Dropdown item 1");
            _contextMenuAutoFill.Items.Add("Dropdown item 2");
            _contextMenuAutoFill.Items.Add("Dropdown item 3");
            _contextMenuAutoFill.Items.Add("Dropdown item 4");

            foreach (ToolStripMenuItem mItem in _contextMenuAutoFill.Items)
                mItem.Click += 
                new System.EventHandler(this.AutoFillToolStripMenuItem_Click);

        private void button1_Click(object sender, EventArgs e)
            button1.ContextMenuStrip = _contextMenuAutoFill;
		(button1, new System.Drawing.Point(0, button1.Height));

        private void AutoFillToolStripMenuItem_Click(object sender, EventArgs e)
            string m = ((ToolStripMenuItem)sender).Text;
            MessageBox.Show("You have clicked '" + m + "'");

This link explains how to create this control using custom control.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Balu Sathish
Software Developer Calpine Technologies
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
fredatcodeproject27-Sep-13 5:34
memberfredatcodeproject27-Sep-13 5:34 
GeneralMy vote of 4 Pin
Champion Chen26-Sep-13 23:12
memberChampion Chen26-Sep-13 23:12 
GeneralMy vote of 3 Pin
ridoy21-Jun-13 23:55
memberridoy21-Jun-13 23:55 
GeneralMy vote of 5 Pin
Darthillian6-Feb-13 1:37
memberDarthillian6-Feb-13 1:37 
GeneralMy vote of 5 Pin
solowilliam6-Aug-11 3:09
membersolowilliam6-Aug-11 3:09 
GeneralMy vote of 3 Pin
Jason Vogel12-May-11 10:28
memberJason Vogel12-May-11 10:28 
GeneralIdea is good, need to be better Pin
MickeyWu12-May-11 4:12
memberMickeyWu12-May-11 4:12 
GeneralRe: Idea is good, need to be better Pin
GregoryW22-Jun-13 0:04
memberGregoryW22-Jun-13 0:04 
GeneralMessage Automatically Removed Pin
11-May-11 5:50
memberHossein Montazeri11-May-11 5:50 
QuestionRe: My vote of 1 Pin
Warrick Procter11-May-11 20:08
memberWarrick Procter11-May-11 20:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151002.1 | Last Updated 26 Sep 2013
Article Copyright 2011 by Balu Sathish
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid