locked
ToolStriptextbox right click context menu RRS feed

  • Question

  • how do you prevent the context menu on a ToolStripText box from
    appearing? Anmd the correllary, how do you add a context menu to the ToolStripText box?
    Saturday, August 11, 2012 12:35 AM

Answers

All replies

  • You can create a Custom ToolStripTextBox control using following code

    public class MyTextBox : ToolStripTextBox
    {
        ContextMenuStrip _contextMenuStrip;
    
        public ContextMenuStrip ContextMenuStrip
        {
            get { return _contextMenuStrip; }
            set { _contextMenuStrip = value; }
        }
    
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (_contextMenuStrip !=null)
                    _contextMenuStrip.Show(Parent.PointToScreen(e.Location));
            }
        }
    }

    Else you can refer following link

    http://stackoverflow.com/questions/283417/how-do-i-add-a-contextmenustrip-to-a-toolstripbutton


    Gaurav Khanna | Microsoft VB.NET MVP

    • Marked as answer by Mike Feng Wednesday, August 22, 2012 2:53 PM
    Saturday, August 11, 2012 12:37 PM
  • Thats answers part 2 of my post. thanks

    Now the 1st part is

    "how do you prevent the context menu on a ToolStripTextbox from appearing?

    Right click on ToolStripTextbox the menu that pops up and the one I want to be rid of is

    that annoying ToolStripTextbox context menu (VS2008)

    Saturday, August 11, 2012 2:43 PM
  • Hi Seepeg,

    How about Thorsten's suggestion which is in your another thread: http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/5a8b62c7-4b33-4f42-87fe-79f872dad806 

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Mike Feng Wednesday, August 22, 2012 2:53 PM
    Tuesday, August 14, 2012 9:20 AM