Can't clone ContextMenu

  • Thread starter Thread starter **Developer**
  • Start date Start date
D

**Developer**

I have a usercontrol in which the IDE generated context menu statement is:

Friend WithEvents ContextMenuThumbnails As System.Windows.Forms.ContextMenu



I want to save the contents of it so I tried:
Private mMenuSaved As ContextMenu = Me.ContextMenuThumbnails.clonemenu



But the compiler says:

C:\Documents and Settings\Cal\My Documents\Visual Studio Projects\CAG
Studio\CAG ControlThumbnails\ControlThumbnails.vb(531):
'System.Windows.Forms.Menu.Protected Sub CloneMenu(menuSrc As
System.Windows.Forms.Menu)' is not accessible in this context because it is
'Protected'.




Is there a way to get around this?





Thanks
 
Hi,

have you tried:

Private mMenuSaved As New ContextMenu
mMenuSaved = Me.ContextMenuThumbnails

Hth Greetz Peter
 
Seems to me that would:
1) Define a new variable mMenuSaved
2) Instantiate a new ContextMenu and reference it in mMenuSaved
3)Then replace that reference with a reference to the present
ContextMenuThumbnails

That is, the end result will be a new reference to the present
ContextMenuThumbnails.

I'm not very knowadgeable about these things so I'm not sure and would like
comments, that is, either confirmation, correction, or denial or the above.

Thanks
 
**Developer** said:
Did you mean to send this to someone else?
I don't see
in my post.
Sorry, I can't believe I missed what this says.

Any way, I just meant I didn't want a new reference to the same data memory
locations but wanted a new variable that reference a new set of data.
 
Hi sorry for the late response,

do you mean something like this:

Dim newCM As New ContextMenu
Dim miNew As MenuItem
For Each mi As MenuItem In ContextMenu1.MenuItems
miNew = New MenuItem(mi.Text)
newCM.MenuItems.Add(miNew)
Next

hth Greetz Peter
 
I'll have to study this.

Thanks


Peter Proost said:
Hi sorry for the late response,

do you mean something like this:

Dim newCM As New ContextMenu
Dim miNew As MenuItem
For Each mi As MenuItem In ContextMenu1.MenuItems
miNew = New MenuItem(mi.Text)
newCM.MenuItems.Add(miNew)
Next

hth Greetz Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top