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

Context Menu on ListView

Hi there,
I fear the answer to this question is going to be very simple but it's me
running around in circles at the moment.

I wish to pop up a context menu on my ListView if and only if I right click
over a selected item.

What I mean by this is that say my list view can hold 10 items but i've only
3 items presently, if i click on the space where there is no ListView item
then i do not wish to show my context menu.

Anyone got any ideas on this?

thanks in advance
Brian
Nov 17 '05 #1
2 28239

ok figured it out

private void OnEventListView_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ListViewHitTestInfo hitTestInfo = HitTest(e.X, e.Y);
if (hitTestInfo.Item != null)
{
//show the context menu strip
cmsOptions.Show(this, e.X, e.Y);
}
}
}

"Brian Keating" wrote:
Hi there,
I fear the answer to this question is going to be very simple but it's me
running around in circles at the moment.

I wish to pop up a context menu on my ListView if and only if I right click
over a selected item.

What I mean by this is that say my list view can hold 10 items but i've only
3 items presently, if i click on the space where there is no ListView item
then i do not wish to show my context menu.

Anyone got any ideas on this?

thanks in advance
Brian

Nov 17 '05 #2
Umm... There's also a ContextMenu_Popup event. You might want to think
about doing it there.

Tom P.
"Brian Keating" <csharp at briankeating.net> wrote in message
news:11**********************************@microsof t.com...

ok figured it out

private void OnEventListView_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ListViewHitTestInfo hitTestInfo = HitTest(e.X, e.Y);
if (hitTestInfo.Item != null)
{
//show the context menu strip
cmsOptions.Show(this, e.X, e.Y);
}
}
}

"Brian Keating" wrote:
Hi there,
I fear the answer to this question is going to be very simple but it's me
running around in circles at the moment.

I wish to pop up a context menu on my ListView if and only if I right
click
over a selected item.

What I mean by this is that say my list view can hold 10 items but i've
only
3 items presently, if i click on the space where there is no ListView
item
then i do not wish to show my context menu.

Anyone got any ideas on this?

thanks in advance
Brian

Nov 17 '05 #3

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

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
4
by: Aaron Queenan | last post by:
How can I use the designer to add a context menu to a class which inherits from a control, e.g. treeview, without adding the context menu to a form? For example, to add a context menu with...
2
by: Dino M. Buljubasic | last post by:
I have several context menus added to my form. The form is displaying items in listviews connected to the context menus. When I click on an item in a list view, a popup context menu shows allowing...
8
by: Sameh Ahmed | last post by:
Hello there i have a context menu linmked to a listview control. I want the context mnu to appear ONLY when i right click on an item and not any place in listview. any ideas? Thanks in advance....
2
by: Darin | last post by:
I have 2 listview's that have the same context menu tied to them. WHen the user opens the context menu and clicks on one of the menu items, how (within the handles mSelPrice_click) method can I...
3
by: J L | last post by:
I have a form with a listview on it and a context menu. I handle the right click event on the listview but after handling the event, the context menu then appears. I would like to disable it if the...
4
by: Fred | last post by:
Hi, I have a list box with a context menu. When I right click the menu appears as expected. However when I select an option on the context menu the menu does not close. The click event on the...
2
by: Bry | last post by:
I have a context menu which is shared between a TreeView and ListView control (both controls show the same information, similar to how Windows Explorer works, so it makes sense to use the same menu...
0
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...

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.