I like to add one context strip along with the inbuilt context strip in text box.How can i achieve this...

7 Years
Discussion Span
Last Post by darkagn

I think you are talking about the TextBox.ContextMenuStrip property? You can simply create a ContextMenuStrip (in Designer or in Code) and assign it to this property. If the property is not set, there is no ContextMenuStrip for the TextBox, that is there is no "inbuilt" ContextMenuStrip.


ContextMenuStrip cms = new ContextMenuStrip();
// add some items here...
// ...
myTextBox.ContextMenuStrip = cms;

Thnks for responce. but i knew that.

When u right click on the text box on run time u can see context strip listed as
undo, paste, cut , copy, delete and select all. Now i like to add another one to that context strip. How can i achieve this...

Edited by Nivass: n/a


That ContextMenuStrip is not standard for a TextBox (which defaults to a null ContextMenuStrip) so either you are using a different control to System.Windows.Forms.TextBox or you have added that strip yourself. You can't have two ContextMenuStrips on a single control, however you could switch between two different strips if you need to.

Alternatively, you could add a ContextMenu (as opposed to a ContextMenuStrip) and this will take precedence over the strip in a right-click operation. What you can then do is listen to the Opening event for your ContextMenu and cancel it from opening if you want the strip to open instead.

Edited by darkagn: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.