I'm trying to dynamically create values for a context menu (popup),
depending upon which node is highlighted in a Treeview control. This is not
a problem, if you select the node with the left mouse button and THEN
right-click (the context menu then displays an item IAW a Tag value
previously assigned to each node). If you only use the right mouse button,
however, it appears that the given node is selected but this is not the
case; it is only highlighted, and all you get is the old value for the
previously selected node, which had to have been selected via the left mouse
button first.
A one-click process seems more natural and intuitive to me; and it should be
possible to select a given node with either mouse button. Any suggestions
as to how to achieve this. Lots of hair pulling so far but no luck.
Regards,
Randall Hale 2 1625
* "Randall Hale" <ha****@ix.netcom.com> scripsit: I'm trying to dynamically create values for a context menu (popup), depending upon which node is highlighted in a Treeview control. This is not a problem, if you select the node with the left mouse button and THEN right-click (the context menu then displays an item IAW a Tag value previously assigned to each node). If you only use the right mouse button, however, it appears that the given node is selected but this is not the case; it is only highlighted, and all you get is the old value for the previously selected node, which had to have been selected via the left mouse button first.
That's a FAQ:
<http://www.google.com/groups?ie=UTF-8&q=Contextmenu+treeview+group%3A*dotnet*>
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Thanks, Herrfried. That did the trick (I've been out of the loop and hadn't
seen this question before).
For quick reference for others, this is what finally worked for my
situation:
Sub ContextMenu1_PopUp ( ByVal o As Object, ByVal e As System.EventArgs )
Handles ContextMenu1.Popup
Dim clickedNode As TreeNode = Treeview1.GetNodeAt (
Treeview1.PointToClient ( Cursor.Position ) )
With ContextMenu1.MenuItems
.Clear ( )
.Add ( clickedNode.Tag)
End With
End Sub
Pretty simple but sequence IS scored. I tried something similar during the
MouseUp event for the Treeview control; passing a Point derived from the
MouseEventArgs to the Treeview's GetNodeAt method, as the documentation
suggests. That doesn't help here, however, because the menu pops up before
the MouseUp is called. I knew I was missing something obvious. ;-)
Thanks All!
Randall hale This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sonia Igla |
last post by:
Hi. I need to perform DBLCLK on TreeView Node.
I try the following:
private static extern int SendMessage(IntPtr hWnd, uint msg, UInt32 wParam,
UInt32 lParam);
private const UInt32...
|
by: Peter |
last post by:
Hello
Thanks for reviewing my question. I would like to know how can I programmatically select a node
Thanks in Advanc
Peter
|
by: Michael C |
last post by:
Hi all,
Quick question about the TreeView control. I'm using code like this to
determine the currently clicked TreeNode in the TreeView.
private void MyTreeView_MouseDown(object sender,...
|
by: Tom |
last post by:
Sorry... new to this. I trying to figure out how to do a page redirect when
someone clicks a treeview node. Does someone have a code snippet for this?
|
by: Gerhard |
last post by:
I have the following code in an .net 2.0 project:
<asp:Panel Runat="server" id="pnlNavigation" CssClass="pnlNavigation"
Width="165px">
<asp:TreeView ID="TreeView1" runat="server"...
|
by: Sam |
last post by:
Hi,
On my main form in my MDI application, I have two treeview, one on the
right, which is actually a UserControl inherited from Treeview, and the
other on the left.
When I click on a node in...
|
by: Daves |
last post by:
Sorry folks but I will be reposting this question from 6/5 until someone
gives me an answer - the question is very easy and so ought the answer to
be. I really need the answer!
-------
I'm...
|
by: Matt MacDonald |
last post by:
Hi All,
I have a form that displays hierarchical categories in a treeview. Ok so
far so good. What I was to do is have users be able to select a node in the
treeview as part of filling out the...
|
by: Joe Cool |
last post by:
Let's say I have a Treeview control on a form. Each leaf node in the
Treeview has a ContextMenuStrip, each with one ToolStripMenuItem, and
all ToolStripMenuItems Click event is handled by a comment...
|
by: auntiejack56 |
last post by:
Hi, I've got a treeview, and I want to display the node text property
that I have
a) clicked on
or
b) highlighted using the up or down arrows
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
| |