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

I need the ContextMenu NOT to show at certain times.

I have the ContextMenu property for a ListBox set at design time. When I
right-click the ListBox, the ContextMenu appears as it should. However, I do
not want the ContextMenu to show when the user right-clicks in the ListBox
but not on a ListItem.

I use the following code to enable/disable the ContextMenu, but I'd rather
have it not show at all. I tried putting ContextMenuStrip1.Hide in the
Catch section, but that doesn't work.

Private Sub lstPeople_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lstPeople.MouseDown

Try

With lstPeople

..SelectedItem = .Items.Item(.IndexFromPoint(e.X, e.Y))

End With

ContextMenuStrip1.Enabled = True

Catch

ContextMenuStrip1.Enabled = False

End Try

End Sub
Jan 7 '06 #1
0 785

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

Similar topics

0
by: Stefan | last post by:
I've a weird problem. I use a contextmenu to do some staff after clicking the contextmenuitem. all works fine on my pc (win2k). If the application runs on the customers pc (NT4) the contextmenu...
0
by: Valerie Hough | last post by:
I have two different cases: 0) I right click the mouse button on a list box on my form, then in the Popup handler for the list box I use SendKeys to send three characters at once (the mnemonics...
0
by: cemino | last post by:
Hi, I got a problem with ContextMenu. I'm using a hot-key (like Ctrl-B) to show contextMenu in my program. Things is like below: contextMenu.Show(Form1, New...
9
by: I_AM_DON_AND_YOU? | last post by:
I have written a VB.Net program. This program has a ConetxtMenu1. ContextMenu1 is very big and has many levels. There are so many procedures and depending upon the logic many times a menu item...
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
7
by: TryingLikeHeck | last post by:
I have a usercontrol on which I've generated a context menu in designer. The properties of the control lists for ContextMenu (none) The menu shows up in the designer window and I can edit it To...
0
by: Jorge | last post by:
Hello I am trying to browse a form and i know it has 3 contextmenus and a mainmenu. Public Sub PercorreMenus(ByVal f As Form) Dim ctl As Control For Each ctl In f.Controls If...
0
by: Ahmad Jalil Qarshi | last post by:
Hi! I have a NotifyIcon and a ContextMenu attached to it. What I want is to show the ContextMenu when the mouse pointer is over the NotifyIcon and hide the contextMenu when the Mouse pointer...
3
by: asharda | last post by:
Hi, I am trying to create a context menu in my application. The context menu takes menu otems from an XML file. In XAML the code is <Grid.ContextMenu> <ContextMenu Name="cm" StaysOpen="true"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.