PC Review


Reply
Thread Tools Rate Thread

This code displays a problem when run

 
 
**Developer**
Guest
Posts: n/a
 
      14th Aug 2005
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








 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      14th Aug 2005
**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
 
Reply With Quote
 
**Developer**
Guest
Posts: n/a
 
      14th Aug 2005
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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When I try to insert ToC, it displays some ToC code =?Utf-8?B?VmVua2F0ZXNo?= Microsoft Word Document Management 3 3rd May 2006 11:18 PM
Re: Displays from VBA Code Dirk Goldgar Microsoft Access Form Coding 7 25th Aug 2004 04:22 PM
Re: Displays from VBA Code ¹Ú¹®¼ö Microsoft Access Form Coding 0 20th Aug 2004 04:44 AM
ie6 displays machine code Brad Alexander Windows XP Internet Explorer 1 27th Oct 2003 05:49 PM
IE6 Displays Code Clyde Ellingwood Windows XP Internet Explorer 1 3rd Jul 2003 02:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:57 PM.