Extending default ContextMenu

Hi. I'm using VB.Net 2005. How do I get the cut copy paste etc. functionality of the default contextmenu for textbox controls, to add to my custom ContextMenuStrip?
-Paul.
[177 byte] By [Paul.Peat] at [2007-12-16]
# 1
I have an example, but on VB6.
SpawnProduction at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2

There isn't a way to merge the items exactly. The best way I can think of do this would be to create a custom ContextMenuStrip and associate it with the text box.

textBox1.ContextMenuStrip = myContextMenuStrip

The setting of a ContextMenuStrip supersedes the built in context menu. Anyway, then populate your ContextMenuStrip with custom items and cover edit commands cordoned off with separators. You can then route the edit commands to the corresponding methods on the textbox (Cut, Copy, and Paste). You'll have to do some state (enabled) maintenance as well. This can be done in the Opening event of the ContextMenuStrip by checking for a selection and/or appropriate clipboard contents.

ErickEllis at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
That helped a lot thanks.

-Paul.

Paul.Peat at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4

This is not really useful when you are trying to use visual inheritance and trying to add new items to the contextmenustrip.

Try this :

Create a usercontrol

Add a textbox

add a contextmenustrip

set the textbox's contextmenustrip to the contextmenustrip you just created.

Add "Cut" And "Copy" to this shortcut.

Set the "Modifier" of the contextmenustrip to "public"

Build the project

Create an inherited userControl, and select the above user control as the base control

in the designer you will see the contextmenustrip.

It will even SEEM LIKE you can add new items to the contextmenustrip...

But add the items, SAVE and close the usercontrol design screen...

Re-open it

Your items are in the form, but DETACHED from the contextMenustrip...

Pretty interesting, isn't it ?

PS: This is the published version of VS 2005

durayakar at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...