PC Review


Reply
Thread Tools Rate Thread

Contextmenu & TreeView

 
 
Peter Zentner
Guest
Posts: n/a
 
      15th Jul 2003
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


 
Reply With Quote
 
 
 
 
Eric Promislow
Guest
Posts: n/a
 
      15th Jul 2003
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:<#(E-Mail Removed)>...
> 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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Treeview ContextMenu Todd A Microsoft Dot NET Compact Framework 4 10th Jan 2005 05:19 PM
TreeView and ContextMenu Todd Acheson Microsoft Dot NET Compact Framework 0 3rd Jan 2005 03:27 AM
TreeView And ContextMenu Question Tiraman :-\) Microsoft VB .NET 2 31st Aug 2004 09:58 PM
Contextmenu & TreeView Peter Zentner Microsoft Dot NET 1 15th Jul 2003 11:02 PM
Contextmenu & TreeView Peter Zentner Microsoft Dot NET Framework Forms 1 15th Jul 2003 11:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:30 PM.