473,386 Members | 1,745 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,386 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 28243

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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.