473,788 Members | 3,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to add mouse right-click event to tree w/out overriding defaul

by default when you right click a tree the control selects the node

if you add a right-click event (so that I can put sepearate ContextMenus
depending on what type of node the user clicked on) then that default
behavior is overrided, and it no longer selects the node the user
right-clicked on. Now my event is wrong because I want to use SelectedNode
but the SelectedNode turns out to be whatever was previously selected instead
of what the user just clicked on.

how do I solve this problem?
Oct 26 '06 #1
1 1792
In article <99************ *************** *******@microso ft.com>,
Mr******@discus sions.microsoft .com says...
by default when you right click a tree the control selects the node

if you add a right-click event (so that I can put sepearate ContextMenus
depending on what type of node the user clicked on) then that default
behavior is overrided, and it no longer selects the node the user
right-clicked on. Now my event is wrong because I want to use SelectedNode
but the SelectedNode turns out to be whatever was previously selected instead
of what the user just clicked on.

how do I solve this problem?
Instead of handling the MouseDown event, you could inherit from the
TreeView and override the OnMouseDown method -- and make sure you call
base.OnMouseDow n() first to let the base class do it's code first (which
should include selecting the node right-clicked on).

--
Patrick Steele
http://weblogs.asp.net/psteele
Oct 26 '06 #2

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

Similar topics

6
30046
by: scot_nery | last post by:
I got this working in all browsers but FF/NS. It's not picking up the event to find the mouse position. In a perfect world, you mouse over the link and a mouse bubble pops up. Thanks for help. scot
3
9357
by: Paul L | last post by:
Anyone know a quick way of determining which direction the mouse cursor is moving (ie. up, down, left, right) from a specified origin? Thanks, Paul L
6
10817
by: Carlos García-Carazo | last post by:
Hello, I am working on a C# application for an industrial machine, using Windows Forms, where the user could look at the screen from a 90 degree rotated position, like he could turn the monitor to leave it standing on its left (or right) side. There are many ways to show a "turned" interface in this case, but the problem is that when he moves the mouse right, in a turned screen the mouse cursor goes down (or up), when he moves it up...
1
19235
by: Benny Raymond | last post by:
In my attempt to make a macro recording program where i can then playback mouse movements i'm running into a big problem: I'm trying to simulate the movement of the mouse to a point on the screen. With my current code the mouse is only moving in the X direction and not in the Y direction (however my debug line is telling me that it's trying to move in the Y as well). I've read everything I could find online, tried some hacky ways of...
3
2714
by: Emjay | last post by:
Newbie needs to know how to set the mouse position.
13
2311
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 well. He is frequently missing the left mouse button and hitting the right, or less often the middle (wheel) buttons. While he is very slowly getting better with practice, the frustration level is high for him as a result of this (he gets very...
5
2390
by: Mike | last post by:
I'm looking for a wireless mouse that which allows me to change the X-Y orientation, so that left is right, right is left, up is down, and down is up. Can anyone point me in the right direction?
7
2991
by: Martijn Mulder | last post by:
When the mouse is over a picture, the user can grow or shrink it by rolling the central mouse wheel. What behavior is typical when the user rolls the wheel away. Will the picture grow or shrink then?
5
7786
by: EggHead | last post by:
Hi all, My development environment is VB 6.0, and my OS is winxp. I would like to know how to find the mouse location at a control when the mouse is point at that control. The problem is that the mouse "whatever" events will not fire since the mouse is hjhack by other control. Anyway, I have the following code and I can check is the mouse over the control or not, however, I cannot find out where the mouse location at that control. Private...
4
6977
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I just gotta fix it. I need to make some calculations on the measurements and VB6 is my language. Yes, the system mouse will corrupt the measurement, but it's an auditing function and that's acceptable.
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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
10172
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
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
8993
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
7517
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
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.