473,772 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treeview Node Loses highlight when context menu opens

Here's what I'm doing to make the right context mnue show up based on
what node was cliked:

private void tvwMenu_MouseUp (object sender, MouseEventArgs e)
{
//Select Node When Right Clicked & Set Context Menu To Use
if( e.Button == MouseButtons.Ri ght )
{
TreeNode node = tvwMenu.GetNode At( new Point( e.X, e.Y ) );
if( node != null )
{
TreeNodeMenuTag tag = (TreeNodeMenuTa g)node.Tag;
tvwMenu.Selecte dNode = node;
tvwMenu.Context MenuStrip = (tag.isMenu) ? cmnuMenuNode :
cmnuProgramNode ;
}
}
}

It works, but unlike the Solution Explorer treeview in VS when you
right click on a node the node loses its highlight. I don't like this
cux it makes it less obvious which node you are operating on. Anyone
know how to fix this?

Thanks.
Nov 16 '05 #1
4 11607
Try setting the treeview's "Hide Selection" property to false.
"Phill" <wa********@yah oo.com> wrote in message
news:ac******** *************** ***@posting.goo gle.com...
Here's what I'm doing to make the right context mnue show up based on
what node was cliked:

private void tvwMenu_MouseUp (object sender, MouseEventArgs e)
{
//Select Node When Right Clicked & Set Context Menu To Use
if( e.Button == MouseButtons.Ri ght )
{
TreeNode node = tvwMenu.GetNode At( new Point( e.X, e.Y ) );
if( node != null )
{
TreeNodeMenuTag tag = (TreeNodeMenuTa g)node.Tag;
tvwMenu.Selecte dNode = node;
tvwMenu.Context MenuStrip = (tag.isMenu) ? cmnuMenuNode :
cmnuProgramNode ;
}
}
}

It works, but unlike the Solution Explorer treeview in VS when you
right click on a node the node loses its highlight. I don't like this
cux it makes it less obvious which node you are operating on. Anyone
know how to fix this?

Thanks.

Nov 16 '05 #2
Thanks for the tip it does improve things having the highlight still
show when the context menu takes focus.

Still, you have to click like 2x in order to right click another node.
Once to cause the context menu to loose focus and again to get the
context menu to appear on the new node.

In VS's Exlorer or even Windows Explorer though you don't have to.
Just right clicking another node (eben if the context menu is already
up) works.

Any idea how to accomplish this?
Nov 16 '05 #3
In your mousedown or up event handler (where you're determining what node
was clicked on), you'll have to programmaticall y set the selection to that
node. If you're relying on the treeview's selected node property, you'll
have to abandon that and call the methods to get the node based on the mouse
position.

--
-Philip Rieck
http://philiprieck.com/blog/

-
"Phill" <wa********@yah oo.com> wrote in message
news:ac******** *************** ***@posting.goo gle.com...
Thanks for the tip it does improve things having the highlight still
show when the context menu takes focus.

Still, you have to click like 2x in order to right click another node.
Once to cause the context menu to loose focus and again to get the
context menu to appear on the new node.

In VS's Exlorer or even Windows Explorer though you don't have to.
Just right clicking another node (eben if the context menu is already
up) works.

Any idea how to accomplish this?

Nov 16 '05 #4
Hello Phill, I'm Willian from Brazil ...

You most change the mouse position for some context. You can use method
PointToClient of treeview object. This method return a point in client
context.
For example:

Point position = myTreeview.Poin tToClient(new Position(e.X, e.Y));
TreeNode node = myTreeview.GetN odeAt(position) ;

Try it!

[ ]'s

Willian

"Phill" wrote:
Here's what I'm doing to make the right context mnue show up based on
what node was cliked:

private void tvwMenu_MouseUp (object sender, MouseEventArgs e)
{
//Select Node When Right Clicked & Set Context Menu To Use
if( e.Button == MouseButtons.Ri ght )
{
TreeNode node = tvwMenu.GetNode At( new Point( e.X, e.Y ) );
if( node != null )
{
TreeNodeMenuTag tag = (TreeNodeMenuTa g)node.Tag;
tvwMenu.Selecte dNode = node;
tvwMenu.Context MenuStrip = (tag.isMenu) ? cmnuMenuNode :
cmnuProgramNode ;
}
}
}

It works, but unlike the Solution Explorer treeview in VS when you
right click on a node the node loses its highlight. I don't like this
cux it makes it less obvious which node you are operating on. Anyone
know how to fix this?

Thanks.

Nov 16 '05 #5

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

Similar topics

2
2521
by: Eric | last post by:
I implemented owner drawing on the main and context menus of my main form. It works fine. There is also a notify icon control that has a context menu. When the icon is in the status bar, it works perfectly fine when it is double-clicked. However, when I try to initialize the notify icon's context menu as an owner-drawn menu, all the text in that menu disappears. Is owner drawing a notify icon's context menu possible? I saw someone...
5
5494
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
2
14315
by: Juan Romero | last post by:
Hey guys, I am trying to detect a node right click event, but I can't seem to find a way do this. The only way I found to get to a point where I know the user clicked the node is by checking the afterselect event of the treeview control. The Event arguments variable has an action property which tells me whether the user clicked the node, or expand it or whatever.
2
3755
by: Claire | last post by:
I've a treeview control containing a root node with several children on a windows form. I select a node with a left mouse button click. I then select one of the other nodes with right mouse click to bring up my context menu. The Popup event of this enables menu items depending on the node selected. The new node highlights, and my context menu pops up but I noticed that the enabled state of the menu items was incorrect. Tracing into my...
2
1340
by: anujzcool | last post by:
Hi All, I want to capture window messages when context menu is opened and user is scrolling in it or just moving his mouse outside it. I tried with all the possible window messages and nothing is getting triggered when context menu is open however when context menu is closed than all the messages are fired. Can someone please help me on this. Thanks and regards Anuj Kapoor
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.