473,320 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

This code displays a problem when run

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


Nov 21 '05 #1
2 1092
**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.MenuItemPasteSpec ial)

End Sub
Nov 21 '05 #2
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" <no@spam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
**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.MenuItemPasteSpec ial)

End Sub

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
2
by: CR | last post by:
having a problem with the final strcpy of filename from *argv into a structure containing an array with 20 elements called fname It seems that strcpy & strncpy aren't stopping after null is found...
0
by: TN Bella | last post by:
Hi, I am trying to get my compare validator to fire properly...Since I have panels the validator wouldn't work properly, the app would fire right but would insert the data regardless and the...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
11
by: Shawn Yates | last post by:
I downloaded TimeLines.zip from (http://www.mvps.org/access/reports/rpt0018.htm) and I think I found a bug in it but I can't seem to fix it. When you open this go to the table and enter a new...
10
by: sara | last post by:
I have been volunteered to write a simple system to help a non-profit enter and track information on the elders they serve. (It's actually a fascinating activity, and very rewarding to be helping...
3
by: divya | last post by:
Hiii, Please read the following piece of code:- function SendToWebServer1(sendto) //sendto string contains a URL { if (document.form1.txtbookedby.value == "") { alert('your name field...
10
by: Doug Robertson | last post by:
First off, I'm a hardware/OS guy. I just write code on the side and I'm completely self taught - so bear in mind my total lack of expertise. I have a program originally written in VB2003 using...
17
by: radio1 | last post by:
Configuration: Access 2002 and SQL Server 2000 using a .ADP Project. I would VERY MUCH appreciate anyone's input into this problem I'm having. I have a form in Access that does not permit...
3
by: massdeletion101 | last post by:
I need help, and when I ask for it around here, it usually goes with little or no replies and help watsoever. It seems the only way to get the message across is to make the title desperate sounding....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.