I wonder why that works because you're removing and then adding
MenuItemPasteSpecial which displayed OK. It's the items of
MenuItemPasteSpecial that didn't.
In any event, that does solve the problem as I presented it but typically
one would not want to clear MenuItemEdit because it would have many items on
it.
I wonder what made you think of that. Do you have any other ideas that may
sove the more general problem?
Thanks
"Chris" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> **Developer** wrote:
>> I've been asking about a Menu problem I have without results.
>>
>> So here is a test case I've developed that shows the problem.
>>
>> Simply create a soultion with one project containg one form and replace
>> the form code with this.
>>
>> Run it, right click and select Edit/Paste Special/Test1
>>
>> Then try to do that again
>>
>> I beleive that Test1 will not show the second time!
>>
>> How come?
>>
>>
>>
>> Thanks
>>
>>
>>
>>
>>
>> Public Class FormlTest
>>
>> Inherits System.Windows.Forms.Form
>>
>> #Region "Windows Form Designer generated code "
>>
>> Public Sub New()
>>
>> MyBase.New()
>>
>> InitializeComponent()
>>
>> End Sub
>>
>> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
>>
>> If disposing Then
>>
>> If Not components Is Nothing Then
>>
>> components.Dispose()
>>
>> End If
>>
>> End If
>>
>> MyBase.Dispose(disposing)
>>
>> End Sub
>>
>> Private components As System.ComponentModel.IContainer
>>
>> Friend WithEvents MenuItemEdit As System.Windows.Forms.MenuItem
>>
>> Friend WithEvents MenuItemPasteSpecial As System.Windows.Forms.MenuItem
>>
>> Private WithEvents ContextMenuEditor As System.Windows.Forms.ContextMenu
>>
>> Private Sub InitializeComponent()
>>
>> Me.ContextMenuEditor = New System.Windows.Forms.ContextMenu
>>
>> Me.MenuItemEdit = New System.Windows.Forms.MenuItem
>>
>> Me.MenuItemPasteSpecial = New System.Windows.Forms.MenuItem
>>
>> '
>>
>> 'ContextMenuEditor
>>
>> '
>>
>> Me.ContextMenuEditor.MenuItems.AddRange(New
>> System.Windows.Forms.MenuItem() {Me.MenuItemEdit})
>>
>> '
>>
>> 'MenuItemEdit
>>
>> '
>>
>> Me.MenuItemEdit.Index = 0
>>
>> Me.MenuItemEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem()
>> {Me.MenuItemPasteSpecial})
>>
>> Me.MenuItemEdit.Text = "Edit"
>>
>> '
>>
>> 'MenuItemPasteSpecial
>>
>> '
>>
>> Me.MenuItemPasteSpecial.Index = 0
>>
>> Me.MenuItemPasteSpecial.Text = "Paste Special"
>>
>> '
>>
>> 'FormlTest
>>
>> '
>>
>> Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
>>
>> Me.BackColor = System.Drawing.Color.Blue
>>
>> Me.ClientSize = New System.Drawing.Size(768, 437)
>>
>> Me.Name = "FormlTest"
>>
>> End Sub
>>
>> #End Region
>>
>> Private Sub FormlEditor_MouseUp(ByVal sender As Object, ByVal e As
>> MouseEventArgs) Handles MyBase.MouseUp
>>
>> If e.Button = MouseButtons.Right Then ContextMenuEditor.Show(Me, New
>> Point(e.X, e.Y))
>>
>> End Sub
>>
>> Private Sub ZZ_Click(ByVal sender As Object, ByVal e As System.EventArgs)
>>
>> End Sub
>>
>> Private Sub ContextMenuEditor_Popup(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles ContextMenuEditor.Popup
>>
>> Dim lMsg As String
>>
>> Dim jnk
>>
>> MenuItemPasteSpecial.MenuItems.Clear()
>>
>> MenuItemPasteSpecial.MenuItems.Add(New MenuItem("Test1", AddressOf
>> ZZ_Click))
>>
>> MenuItemPasteSpecial.MenuItems.Add(New MenuItem("Test2", AddressOf
>> ZZ_Click))
>>
>> End Sub
>>
>> End Class
>>
>>
>>
>>
>>
>>
>>
>>
>
>
> This code should fix your problem. Looks like you have to refresh the
> menu with MenuItemPasteSpecial after you make a change like that....
>
> Private Sub ContextMenuEditor_Popup(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles ContextMenuEditor.Popup
>
>
> MenuItemPasteSpecial.MenuItems.Clear()
>
> MenuItemPasteSpecial.MenuItems.Add(New MenuItem("Test1", AddressOf
> ZZ_Click))
>
> MenuItemPasteSpecial.MenuItems.Add(New MenuItem("Test2", AddressOf
> ZZ_Click))
>
> MenuItemEdit.MenuItems.Clear()
>
> Me.MenuItemEdit.MenuItems.Add(Me.MenuItemPasteSpecial)
>
> End Sub
|