I am sure you know how to add the predefined TextBox or ComboBox controls to a Windows Forms context Menu:

Just wanted to quickly show you how you can add your own custom controls to that context menu by using the ToolStripControlHost class, like this (the yellow panel is a user control):

Here is a short video:

And here is the code:

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 WindowsFormsApplication1
    public partial class Form1 : Form
        public Form1()

            //instance my control
            UserControl1 c = new UserControl1();

            //pass as parameter to ToolStripControlHost instance
            ToolStripControlHost host = new ToolStripControlHost(c);

            //add ToolStripControlHost object to context menu. simple!


AddThis Social Bookmark Button

Monday, 19 January 2009 17:41:23 (GMT Standard Time, UTC+00:00)
Heh :D I have searched something like that few days ago but I didn't find by googling and had to "waste time" ;) for my own experiments and tries. I think this post will be useful for many people, thanks anyway :)

I like your youtube presentations :) Your nice blog is already in my feeds :)

Monday, 19 January 2009 17:42:41 (GMT Standard Time, UTC+00:00)
eh, btw: to other readers ;) Same method you can use for popular StatusStrip component.
Monday, 19 January 2009 20:15:28 (GMT Standard Time, UTC+00:00)
Thanks for your comments Marek!
I think I have to lower down the screen resolution before. It looks kind of blurry. I will try that in the next post :)
Friday, 15 May 2009 21:29:07 (GMT Daylight Time, UTC+01:00)
cool ! thnx for the code
Jarno Burger
Monday, 08 February 2010 19:46:22 (GMT Standard Time, UTC+00:00)
Very Very good and usefull code
Your are great, man !
Comments are closed.