473,387 Members | 1,321 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,387 software developers and data experts.

ContextMenus??

Hi All:

I have a contextmenu with each menu item comprising of a set of child
menus. This contextmenu is attached to an image control and is
displayed only when the user right-clicks on the image control. I am
having trouble in clearing out the contextmenu when the user
right-clicks and selects a menu option. What happens is that while the
contextmenu itself vanishes it leaves a small rectangular box on the
screen which only vanishes when I manually do an ALT-TAB into another
window and go back to my window with the contextmenu. The code I have
within the event handler of the menu option is as below:

'Somewhere, I attach an event handler to the menu
m.MenuItems.Add("&Event for Alarm ", New System.EventHandler(AddressOf
Me.JumpTo_OnClick))
..
..
..
'Event handler for the menu option
Protected Sub JumpTo_OnClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
...
For Each mnuItem As MenuItem In ContextMenu1.MenuItems
mnuItem.Enabled = False
mnuItem.Visible = False
mnuItem = Nothing
Next
ImageControl.ContextMenu = Nothing
ImageControl.Invalidate()
End Sub

Any suggestions as to the best way of clearing out a context menu is
most appreciated.

--Karthik
Nov 20 '05 #1
2 989
When selecting the Options of the Contextmenu. Try using the MouseUp event
not the mouseDown

OHM

Karthik Vazhkudai wrote:
Hi All:

I have a contextmenu with each menu item comprising of a set of child
menus. This contextmenu is attached to an image control and is
displayed only when the user right-clicks on the image control. I am
having trouble in clearing out the contextmenu when the user
right-clicks and selects a menu option. What happens is that while the
contextmenu itself vanishes it leaves a small rectangular box on the
screen which only vanishes when I manually do an ALT-TAB into another
window and go back to my window with the contextmenu. The code I have
within the event handler of the menu option is as below:

'Somewhere, I attach an event handler to the menu
m.MenuItems.Add("&Event for Alarm ", New System.EventHandler(AddressOf
Me.JumpTo_OnClick))
.
.
.
'Event handler for the menu option
Protected Sub JumpTo_OnClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
...
For Each mnuItem As MenuItem In ContextMenu1.MenuItems
mnuItem.Enabled = False
mnuItem.Visible = False
mnuItem = Nothing
Next
ImageControl.ContextMenu = Nothing
ImageControl.Invalidate()
End Sub

Any suggestions as to the best way of clearing out a context menu is
most appreciated.

--Karthik


Regards - OHM# OneHandedMan{at}BTInternet{dot}com
Nov 20 '05 #2
* ka*******@yahoo.com (Karthik Vazhkudai) scripsit:
'Event handler for the menu option
Protected Sub JumpTo_OnClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
...
For Each mnuItem As MenuItem In ContextMenu1.MenuItems
mnuItem.Enabled = False
mnuItem.Visible = False
mnuItem = Nothing
Next
ImageControl.ContextMenu = Nothing
ImageControl.Invalidate()
End Sub


Why don't you remove the items with
'ContextMenu1.MenuItem1.Items.Remove(...)'?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

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

Similar topics

0
by: Supa Hoopsa | last post by:
I have assigned a contextmenu to a datagrid in my WINDOWS application and I want to use keyboard shortcuts. I have assigned a shortcut - lets say ctrlV - but do I need to assign a handler in the...
1
by: sho_nuff | last post by:
Hello all, Is it possible to have column specific context menus? so, if i have three columns containing different objects / info, i could have a context menu corresponding to each one? ...
2
by: Matthias S. | last post by:
Hi, I'm looking for a decent way to manage Commands in my Application. As in many applications, a Command can be triggered through various actions (Click on the Menu, Click on the ContextMenu,...
0
by: Just Me | last post by:
UsercontrolA is on UsercontrolB If UsercontrolB merges the contextnemu of UsercontrolA ContextMenuB.MergeMenu(ControlA1.ContextMenuA) Usercontrol A needs to know that happened.
0
by: Paul Bromley | last post by:
Can anyone tell me if it is possible to use a contextmenu from my application as a contextmenu for an external application - i.e. suppress the centextmenu of the external application. Altrenativley...
5
by: Michael Sander | last post by:
Hi, I found out, that a simple Form, created only with the designer, wont Dispose its contextmenu if you show the form, right-click it, and dispose the form afterwards. This isnt really what I...
2
by: PromisedOyster | last post by:
I like what Microsoft has done with their ContextMenus on their bowser based WindowsLive email (formerly hotmail). Does anyone know how they acheived this? Are there any third party products...
0
by: MrNobody | last post by:
I want to display different menu item options depending on what the user right-clicks on the tree. I cant figure out how though, I currently tried to create separate ContextMenu objects in a...
1
by: ckid50 | last post by:
To start off I'm currently using explorer and have no intention of switching to an alternative shell. I've been trying to add a dropdown start menu to my context menu and have currently been...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.