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

Contextmenu & TreeView

Hi all,

if I assign a context menu to a treeview and popup the contextmenu with the
APP-key the context menu appears in the center of the treeview control and
not at the selected treenode. Is there a chance to change this behaviour?

Regards

Peter
Jul 19 '05 #1
1 5744
I was just struggling with this exact same problem, and came up with a
solution which I like/dislike as much as the other suggestions:

private void tvX_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) {
if (e.Button == MouseButtons.Right) {
TreeNode tn = tvX.GetNodeAt(e.X, e.Y);
if (tn == null) {
return;
}
// This is awkward
if (tn.ImageIndex == 2) {
tvX.ContextMenu = null;
} else {
tvX.SelectedNode = tn;
tvX.ContextMenu = ctxtMenu_tvX;
}
}
}

BTW, my setting the selected node is my solution to another reasonably
FAQ in this group (and with other UI frameworks I've used): how to map
a context menu item selection to a node in the tree.

If someone has an elegant solution to either of these problems, one that
preferably doesn't involve hooking the Win32 event loop, I would
appreciate a post.

- Eric

"Peter Zentner" <Peter.Zentner@_RE_MOVE_web.de> wrote in message news:<#S**************@tk2msftngp13.phx.gbl>...
Hi all,

if I assign a context menu to a treeview and popup the contextmenu with the
APP-key the context menu appears in the center of the treeview control and
not at the selected treenode. Is there a chance to change this behaviour?

Regards

Peter

Jul 19 '05 #2

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

Similar topics

1
by: Peter Zentner | last post by:
Hi all, if I assign a context menu to a treeview and popup the contextmenu with the APP-key the context menu appears in the center of the treeview control and not at the selected treenode. Is...
2
by: Grant | last post by:
Gday, Ive added a contextmenu to my form and added some text to the drop down list. I have a treeview control where I want to use this context menu function. This is as far as I have got. Ive...
1
by: Roland Wolters | last post by:
Hi, My treeview has a contextmenu. Using this menu the user can perform an action on a node. However, sometimes I do not want the contextmenu to popup. So I catch the treeview_popup event,...
5
by: Sender | last post by:
In my VB.Net in the Toolbox I have noticed two things: (1) All the controls like Button, TextBox, MainMenu, Checkbox etc. have the same icon in the Toolbox. (That icon is dimmed and is of...
3
by: Mika Mähönen | last post by:
Hello! I have Windows Form application containing StatusBar (sb below) and also ContextMenu for this StatusBar. StatusBar contains 2 panels, and I want to show ContextMenu only if the...
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...
2
by: Tiraman :-\) | last post by:
Hi Everyone, i have a treeview that look like this. Node1 nodechild1.1 nodechild1.2 nodechild1.3 Node2 nodechild2.1
0
by: Peter van der Veen | last post by:
Hi I have a treeview and a bound contextmenu to delete a node. When the user rightclicks the node the menu pops up and one can chosse delete. So far so good. But .... When i use...
1
by: MrNobody | last post by:
I overrided a TreeView control and then overrided it's MouseClick event like so: protected override void OnMouseClick(MouseEventArgs e) { // base.OnMouseClick(e); TreeNode node =...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.