Hi,

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

Recommended Answers

All 3 Replies

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.

Example:

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...

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.