472,958 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How can I tell a mouse right clicks over a listview item that's in

How can I tell a mouse right clicks over a listview item that's in a
container panel. I only want to display a popup menu if the user right click
the mouse over an item on the Listview. I don't not want to display this
menu if a node selected on the listview but user right click over the empty
space of the panel that contain the listview.

The problem here is when I use the Listview's Click Event, I don't have ways
to verify if the right mouse button is clicked, but with this event only
occurs if the user is clicking on one of the item of the Listview control.

If I use the ListView's MouseClick event, then I can't verify if the right
click occurs over a Listview item. Can someone tell me how to solve this
problem? Thanks.
--
Thanks.
Jul 27 '06 #1
4 10535
Try the MouseUp event instead. It has a MouseEventArgs as a parameter.
You can do a "if (e.Button == MouseButtons.Right)"...

"Pucca" <Pu***@discussions.microsoft.comwrote in message
news:F1**********************************@microsof t.com...
How can I tell a mouse right clicks over a listview item that's in a
container panel. I only want to display a popup menu if the user right
click
the mouse over an item on the Listview. I don't not want to display this
menu if a node selected on the listview but user right click over the
empty
space of the panel that contain the listview.

The problem here is when I use the Listview's Click Event, I don't have
ways
to verify if the right mouse button is clicked, but with this event only
occurs if the user is clicking on one of the item of the Listview control.

If I use the ListView's MouseClick event, then I can't verify if the right
click occurs over a Listview item. Can someone tell me how to solve this
problem? Thanks.
--
Thanks.

Jul 27 '06 #2
hopefully this wiil help you.,

/*------------------------------- code
--------------------------------*/
if ((e.Button == MouseButtons.Right) &&
(this.lvClients.SelectedItems.Count != 0))// &&
//(this.lvClients.SelectedItems[0].Focused == true))
{

CheckMenuItemEnable();
this.contextMenu.Show(this.lvClients,new Point(e.X,e.Y));
}
Sincerely,
simida

Pucca wrote:
How can I tell a mouse right clicks over a listview item that's in a
container panel. I only want to display a popup menu if the user right click
the mouse over an item on the Listview. I don't not want to display this
menu if a node selected on the listview but user right click over the empty
space of the panel that contain the listview.

The problem here is when I use the Listview's Click Event, I don't have ways
to verify if the right mouse button is clicked, but with this event only
occurs if the user is clicking on one of the item of the Listview control.

If I use the ListView's MouseClick event, then I can't verify if the right
click occurs over a Listview item. Can someone tell me how to solve this
problem? Thanks.
--
Thanks.
Jul 27 '06 #3
Thank you Brendan but I'm not able to tell if the mouse was click over an
item on the Listview control. The listview control is in the right panel of
a container. If the user clicks on the blank space in the panel but not on
any particualr item on the listview control then I don't want to popup the
contextmenustrip.
--
Thanks.
"Brendan Green" wrote:
Try the MouseUp event instead. It has a MouseEventArgs as a parameter.
You can do a "if (e.Button == MouseButtons.Right)"...

"Pucca" <Pu***@discussions.microsoft.comwrote in message
news:F1**********************************@microsof t.com...
How can I tell a mouse right clicks over a listview item that's in a
container panel. I only want to display a popup menu if the user right
click
the mouse over an item on the Listview. I don't not want to display this
menu if a node selected on the listview but user right click over the
empty
space of the panel that contain the listview.

The problem here is when I use the Listview's Click Event, I don't have
ways
to verify if the right mouse button is clicked, but with this event only
occurs if the user is clicking on one of the item of the Listview control.

If I use the ListView's MouseClick event, then I can't verify if the right
click occurs over a Listview item. Can someone tell me how to solve this
problem? Thanks.
--
Thanks.


Jul 27 '06 #4
I needed to do this a while ago, there may be a better way, but what I did
was this:

When the Right Mouse Button Is Pressed:

private void listBox1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
{
int itemPos = e.Y / listBox1.ItemHeight;
if (itemPos <= listBox1.Items.Count)
{
//Display your Context Menu.
// If you want the details of which item was clicked on its
available with listBox1.Items[itemPos].
}
}
}

Cheers,

Chris.

"Pucca" <Pu***@discussions.microsoft.comwrote in message
news:F1**********************************@microsof t.com...
How can I tell a mouse right clicks over a listview item that's in a
container panel. I only want to display a popup menu if the user right
click
the mouse over an item on the Listview. I don't not want to display this
menu if a node selected on the listview but user right click over the
empty
space of the panel that contain the listview.

The problem here is when I use the Listview's Click Event, I don't have
ways
to verify if the right mouse button is clicked, but with this event only
occurs if the user is clicking on one of the item of the Listview control.

If I use the ListView's MouseClick event, then I can't verify if the right
click occurs over a Listview item. Can someone tell me how to solve this
problem? Thanks.
--
Thanks.

Jul 27 '06 #5

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

Similar topics

5
by: John Champaign | last post by:
Hi all, I'm working on an educational applet for a child with special needs. He's got a bit of a trick to make my life more difficult... To interact with the applet he needs to click on...
3
by: mitsura | last post by:
Hi, I have included a small listing. The test program opens a panel and show a bitmap. What I want is to when the mouse is over the bitmap panel, I want to trap the left mouse click. The...
3
by: TM | last post by:
My Windows Form application has a ListView control, it has 3 columns. I use onMouseUp event to capture the user's x,y mouse coordinates. How do I use these X & Y to find out the excact column and...
13
by: James Bond | last post by:
Hello. My 80+ year old father has recently decided to get his first computer. Due to his age (and I suspect lack of playing pong as a child like I did) he lacks the manual dexterity to use a mouse...
1
by: .NetHelpWanted | last post by:
Hi All, I need a solution for the following scenario. I have 2 treeviews and one listview. the listview is populated with the contents of the treeview clicked. I have implemeted drag and...
3
by: Steve Long | last post by:
I hope this isn't too stupid of a question but I'm looking for a way to change an item in a listview control when the mouse moves over it. I'd like to change its color and underline it for a...
0
by: Nickneem | last post by:
I' m trying to disable all right mouse clicks by using the vbAccelerator Windows Hooks Library The small (systray / console) app. must catch all (right) mouseclicks before they are received by...
1
by: Sim | last post by:
Hello NG, I try to use drag and drop function between two list views. For this I found following code: ...
2
by: james | last post by:
Hello I'm implementing drag and drop between two listviews (in detail view mode). When I drag an item from box a to box b, I then process information relating to the two items. The item from...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.