473,406 Members | 2,377 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,406 software developers and data experts.

Showing context menu on a right click

Hi,

I am trying to show a context menu on a right click in some of my
controls. I want to show it at the right location. However it is
getting shown away from the mouse click location. Here is the code:
private void QueryTreeView_Clicked(object sender, EventArgs
args)
{
MouseEventArgs margs = (MouseEventArgs)args;
if (margs.Button ==
System.Windows.Forms.MouseButtons.Right)
{
TreeNode currentNode =
QueryTreeView.GetNodeAt(margs.X, margs.Y);
if (currentNode != null)
{
MenuItem[] items = new MenuItem[4];
if(currentNode.ImageIndex == 0)
{
items[0] = new MenuItem("Group");
items[1] = new MenuItem("Edit Filter");
items[2] = new MenuItem("Delete");
items[3] = new MenuItem("xxx");
System.Windows.Forms.ContextMenu cmenu = new
ContextMenu(items);
cmenu.Show(this, new Point(margs.X, margs.Y))
}
}
}
}
Am I missing something?
Thanks,
Avanti

Feb 21 '07 #1
1 4439
Check this link..

http://www.windowsforms.net/FAQs/def...egoryID=3&Subc
ategoryID=71&tabindex=3

--
rajagopal

*** Sent via Developersdex http://www.developersdex.com ***
Feb 21 '07 #2

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

Similar topics

8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
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...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
2
by: Ron M. Newman | last post by:
Hi, Just need a little advice. Id like to build *dynamic* context menus for tree nodes. I'm pretty versed in building context menus and attaching them to tree nodes. My question is, what...
3
by: coltrane | last post by:
Can someone direct me to a reference that describes how to create a context menu for a selected row in a datagrid? I have come across many threads regarding context menus and datagrids but they all...
2
by: travelrats | last post by:
Hi Here's my problem - I've been trying to figure this out for a while and ran out of ideas... <div> id1 contains <div> id2 (a geographical map) <div> id2 contains a context menu made out of...
2
by: Andreas Mueller | last post by:
Hi All, I'm trying to show a context menu during a drag drop operation similar to the windows explorers right click drag and drop behavior (A full working sample is at the end of the post): ...
0
by: boeroboy | last post by:
Hi all. I know there is a lot of mystery around the desktop context menu. Plenty of brickerbrack about adding shell menu extensions, but not much on shownig it. Using ShellContextMenu interfaces,...
4
by: Karl | last post by:
Hi all, I want to write an application that is launched from the context menu in Windows Explorer/Computer. That is to say, when I am browsing around my hard drive and get to any location I...
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?
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.