473,626 Members | 3,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treeview Help

Hi,

I am using treeview as my menu.
my menu is like the following

+ Users & Groups
- Users
-Groups
+ Departmenuts
- Engineering
- Business

Currently, I am using mouse down event and trigger my mouse right click.
so when my mouse cursor is in the treeview, and I right click my mouse, my
context menu1 will show up.

but, what I want to do is like the following

When i right click the - Users - pop up context menu1
When I right click the - Groups - pop up context menu2
When I right click the - Engineering - pop up context menu3
When I right click the - Business - pop up context menu4

When I right click the + Users & Groups, nothing will pop up
When I right click the + Departments, nothing will pop up

how to do that ? pls guide me.

Nov 20 '05 #1
5 1547
Hi,

Use contextmenu.sho w in the mousedown event.

Ken
-------------------
" A-PK" <pi********@hot mail.com> wrote in message
news:ua******** ******@tk2msftn gp13.phx.gbl...
Hi,

I am using treeview as my menu.
my menu is like the following

+ Users & Groups
- Users
-Groups
+ Departmenuts
- Engineering
- Business

Currently, I am using mouse down event and trigger my mouse right click.
so when my mouse cursor is in the treeview, and I right click my mouse, my
context menu1 will show up.

but, what I want to do is like the following

When i right click the - Users - pop up context menu1
When I right click the - Groups - pop up context menu2
When I right click the - Engineering - pop up context menu3
When I right click the - Business - pop up context menu4

When I right click the + Users & Groups, nothing will pop up
When I right click the + Departments, nothing will pop up

how to do that ? pls guide me.

Nov 20 '05 #2
To elaborate further on Ken's reply:

In the mousedown event:
1. check to see if the right mouse button was clicked
2. If yes, detect which node was clicked
3. create the appropriate context menu
4. show the context menu

--------------------
From: "Ken Tucker [MVP]" <vb***@bellsout h.net>
References: <ua************ **@tk2msftngp13 .phx.gbl>
Subject: Re: Treeview Help
Date: Thu, 26 Feb 2004 07:15:27 -0500
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#8************ *@TK2MSFTNGP11. phx.gbl>
Newsgroups: microsoft.publi c.dotnet.genera l,microsoft.pub lic.dotnet.lang uages.vb,micros o
ft.public.vstud io.development, microsoft.publi c.vstudio.gener alNNTP-Posting-Host: adsl-18-39-198.mco.bellsou th.net 68.18.39.198
Path: cpmsftngxa06.ph x.gbl!cpmsftngx a09.phx.gbl!TK2 MSFTNGP08.phx.g bl!TK2MSFTNGP11 .
phx.gblXref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:184878 microsoft.publi c.vstudio.devel opment:4455
microsoft.publi c.vstudio.gener al:5658 microsoft.publi c.dotnet.genera l:126200X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

Hi,

Use contextmenu.sho w in the mousedown event.

Ken
-------------------
" A-PK" <pi********@hot mail.com> wrote in message
news:ua******* *******@tk2msft ngp13.phx.gbl.. .
Hi,

I am using treeview as my menu.
my menu is like the following

+ Users & Groups
- Users
-Groups
+ Departmenuts
- Engineering
- Business

Currently, I am using mouse down event and trigger my mouse right click.
so when my mouse cursor is in the treeview, and I right click my mouse, my context menu1 will show up.

but, what I want to do is like the following

When i right click the - Users - pop up context menu1
When I right click the - Groups - pop up context menu2
When I right click the - Engineering - pop up context menu3
When I right click the - Business - pop up context menu4

When I right click the + Users & Groups, nothing will pop up
When I right click the + Departments, nothing will pop up

how to do that ? pls guide me.



Nov 20 '05 #3
my problem is how to detech which node that i click ?

"Francis Ingels [MSFT]" <ringels@subtra ct_this_field.m icrosoft.com> wrote in
message news:XW******** *****@cpmsftngx a06.phx.gbl...
To elaborate further on Ken's reply:

In the mousedown event:
1. check to see if the right mouse button was clicked
2. If yes, detect which node was clicked
3. create the appropriate context menu
4. show the context menu

--------------------
From: "Ken Tucker [MVP]" <vb***@bellsout h.net>
References: <ua************ **@tk2msftngp13 .phx.gbl>
Subject: Re: Treeview Help
Date: Thu, 26 Feb 2004 07:15:27 -0500
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#8************ *@TK2MSFTNGP11. phx.gbl>
Newsgroups:

microsoft.publi c.dotnet.genera l,microsoft.pub lic.dotnet.lang uages.vb,micros o ft.public.vstud io.development, microsoft.publi c.vstudio.gener al
NNTP-Posting-Host: adsl-18-39-198.mco.bellsou th.net 68.18.39.198
Path:

cpmsftngxa06.ph x.gbl!cpmsftngx a09.phx.gbl!TK2 MSFTNGP08.phx.g bl!TK2MSFTNGP11 . phx.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:184878

microsoft.publi c.vstudio.devel opment:4455
microsoft.publi c.vstudio.gener al:5658

microsoft.publi c.dotnet.genera l:126200
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

Hi,

Use contextmenu.sho w in the mousedown event.

Ken
-------------------
" A-PK" <pi********@hot mail.com> wrote in message
news:ua******* *******@tk2msft ngp13.phx.gbl.. .
Hi,

I am using treeview as my menu.
my menu is like the following

+ Users & Groups
- Users
-Groups
+ Departmenuts
- Engineering
- Business

Currently, I am using mouse down event and trigger my mouse right click. so when my mouse cursor is in the treeview, and I right click my mouse, my context menu1 will show up.

but, what I want to do is like the following

When i right click the - Users - pop up context menu1
When I right click the - Groups - pop up context menu2
When I right click the - Engineering - pop up context menu3
When I right click the - Business - pop up context menu4

When I right click the + Users & Groups, nothing will pop up
When I right click the + Departments, nothing will pop up

how to do that ? pls guide me.


Nov 20 '05 #4
Hi,

Private Sub TreeView1_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles TreeView1.Mouse Down

Dim n As TreeNode

Dim myContextMenu As ContextMenu

If e.Button = MouseButtons.Ri ght Then

Try

n = TreeView1.GetNo deAt(e.X, e.Y)

' figure out which menu to display

myContextMenu.S how(TreeView1, New Point(e.X, e.Y))

Catch ex As Exception

'didn't click on a node ignore the event

End Try

End If

End Sub

Ken

---------------------

" A-PK" <pi********@hot mail.com> wrote in message
news:Ow******** *****@tk2msftng p13.phx.gbl...
my problem is how to detech which node that i click ?

"Francis Ingels [MSFT]" <ringels@subtra ct_this_field.m icrosoft.com> wrote in message news:XW******** *****@cpmsftngx a06.phx.gbl...
To elaborate further on Ken's reply:

In the mousedown event:
1. check to see if the right mouse button was clicked
2. If yes, detect which node was clicked
3. create the appropriate context menu
4. show the context menu

--------------------
From: "Ken Tucker [MVP]" <vb***@bellsout h.net>
References: <ua************ **@tk2msftngp13 .phx.gbl>
Subject: Re: Treeview Help
Date: Thu, 26 Feb 2004 07:15:27 -0500
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#8************ *@TK2MSFTNGP11. phx.gbl>
Newsgroups:

microsoft.publi c.dotnet.genera l,microsoft.pub lic.dotnet.lang uages.vb,micros o
ft.public.vstud io.development, microsoft.publi c.vstudio.gener al
NNTP-Posting-Host: adsl-18-39-198.mco.bellsou th.net 68.18.39.198
Path:

cpmsftngxa06.ph x.gbl!cpmsftngx a09.phx.gbl!TK2 MSFTNGP08.phx.g bl!TK2MSFTNGP11 .
phx.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:184878

microsoft.publi c.vstudio.devel opment:4455
microsoft.publi c.vstudio.gener al:5658

microsoft.publi c.dotnet.genera l:126200
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

Hi,

Use contextmenu.sho w in the mousedown event.

Ken
-------------------
" A-PK" <pi********@hot mail.com> wrote in message
news:ua******* *******@tk2msft ngp13.phx.gbl.. .
> Hi,
>
> I am using treeview as my menu.
> my menu is like the following
>
> + Users & Groups
> - Users
> -Groups
> + Departmenuts
> - Engineering
> - Business
>
> Currently, I am using mouse down event and trigger my mouse right click.> so when my mouse cursor is in the treeview, and I right click my
mouse, my
> context menu1 will show up.
>
> but, what I want to do is like the following
>
> When i right click the - Users - pop up context menu1
> When I right click the - Groups - pop up context menu2
> When I right click the - Engineering - pop up context menu3
> When I right click the - Business - pop up context menu4
>
> When I right click the + Users & Groups, nothing will pop up
> When I right click the + Departments, nothing will pop up
>
> how to do that ? pls guide me.
>
>
>


Nov 20 '05 #5
Hy Ken,

in addition to this:

how can I select a treenode with the MouseButtons.Ri ght event if there is no
contextmenu?

I build up a treeview with 3 levels. Only if the second level is selected,
there should be a contextmenu.
This works without problems. In between this level I can select the next
node with the mouseButtons.Ri ght because there is a contextmenu.
If I try to select a node of the first or third level , it gets selected by
holding the mousedown, but with mouseup it jumps back to the origin.
Is there a possibility to handle this?

Greetings Joerg

"Ken Tucker [MVP]" <vb***@bellsout h.net> schrieb im Newsbeitrag
news:u6******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Private Sub TreeView1_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles TreeView1.Mouse Down

Dim n As TreeNode

Dim myContextMenu As ContextMenu

If e.Button = MouseButtons.Ri ght Then

Try

n = TreeView1.GetNo deAt(e.X, e.Y)

' figure out which menu to display

myContextMenu.S how(TreeView1, New Point(e.X, e.Y))

Catch ex As Exception

'didn't click on a node ignore the event

End Try

End If

End Sub

Ken

---------------------

" A-PK" <pi********@hot mail.com> wrote in message
news:Ow******** *****@tk2msftng p13.phx.gbl...
my problem is how to detech which node that i click ?

"Francis Ingels [MSFT]" <ringels@subtra ct_this_field.m icrosoft.com> wrote
in
message news:XW******** *****@cpmsftngx a06.phx.gbl...
To elaborate further on Ken's reply:

In the mousedown event:
1. check to see if the right mouse button was clicked
2. If yes, detect which node was clicked
3. create the appropriate context menu
4. show the context menu

--------------------
>From: "Ken Tucker [MVP]" <vb***@bellsout h.net>
>References: <ua************ **@tk2msftngp13 .phx.gbl>
>Subject: Re: Treeview Help
>Date: Thu, 26 Feb 2004 07:15:27 -0500
>Lines: 40
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <#8************ *@TK2MSFTNGP11. phx.gbl>
>Newsgroups:

microsoft.publi c.dotnet.genera l,microsoft.pub lic.dotnet.lang uages.vb,micros o
ft.public.vstud io.development, microsoft.publi c.vstudio.gener al
>NNTP-Posting-Host: adsl-18-39-198.mco.bellsou th.net 68.18.39.198
>Path:

cpmsftngxa06.ph x.gbl!cpmsftngx a09.phx.gbl!TK2 MSFTNGP08.phx.g bl!TK2MSFTNGP11 .
phx.gbl
>Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:184878 microsoft.publi c.vstudio.devel opment:4455
microsoft.publi c.vstudio.gener al:5658

microsoft.publi c.dotnet.genera l:126200
>X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb
>
>Hi,
>
> Use contextmenu.sho w in the mousedown event.
>
>Ken
>-------------------
>" A-PK" <pi********@hot mail.com> wrote in message
>news:ua******* *******@tk2msft ngp13.phx.gbl.. .
>> Hi,
>>
>> I am using treeview as my menu.
>> my menu is like the following
>>
>> + Users & Groups
>> - Users
>> -Groups
>> + Departmenuts
>> - Engineering
>> - Business
>>
>> Currently, I am using mouse down event and trigger my mouse right

click.
>> so when my mouse cursor is in the treeview, and I right click my mouse, my
>> context menu1 will show up.
>>
>> but, what I want to do is like the following
>>
>> When i right click the - Users - pop up context menu1
>> When I right click the - Groups - pop up context menu2
>> When I right click the - Engineering - pop up context menu3
>> When I right click the - Business - pop up context menu4
>>
>> When I right click the + Users & Groups, nothing will pop up
>> When I right click the + Departments, nothing will pop up
>>
>> how to do that ? pls guide me.
>>
>>
>>
>
>
>



Nov 20 '05 #6

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

Similar topics

2
2421
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 WM_LBUTTONDBLCLK = 0x203; pTreeNode.TreeView.SelectedNode = pTreeNode;
4
10129
by: Karim El Jed | last post by:
Hi, I'm trying to expand a special Node of my TreeView from Codebehind. I have a TreeView on a page for navigating to another site. On the other tsite here is the same TreeView more precisely a new TreeView with the same nodes ;) So I would like to keep the expanding state of the first Tree for the second one on the next page. At least the last selected node (path will be saved in query string) should be expanded.
2
1542
by: DJG | last post by:
I need some help with a TreeView control in VB.Net I've got a datatable with about 8000 rows. 500 are 'folders', and the other 7500 rows are 'jobs'. It's a logical representation of some data, and not a physical drive. Each row has: master_key (unique id) folder_name (name for the user to see) parent_key (the master_key of the parent folder)
3
10139
by: Jan Wrage | last post by:
Hi! I would like to implement a treeview in my existing application. It should show my entire Active-Directory structure, i.e. all Groups, Containers and OUs. Could somebody help me with that. Im trying for about 3 hours but can't get it to work. Thank you!
14
15078
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
3
3817
by: christof | last post by:
I've got a really easy problem, please help me: There are two pages in one I'm creating a TreeView like that: TreeView dbTree = new TreeView(); TreeNode dbTreeRoot = new TreeNode("Root"); dbTree.Nodes.Add(dbTreeRoot); .. ..
10
2347
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a top border. Is it possible to have more than 1 style at the same level (parent node) when using a SiteMap? I want it to appear something like this and I can only find a way to either have the border on all root nodes or none at all. In...
8
12750
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 form. I only want to allow single selection, so using checkboxes is out of the question. It works as is, but it makes the form very cumbersome if every time that a user selects a node, the whole page has to reload. Is there a way to have a node...
7
7833
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 event handler. How do I determine which Treeview Node signalled the menu event in the common event handler?
2
5500
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created programmatically. And I want to bind the selection of a TreeNode (which is a record) from the database) to a DetailsView which shows the datatable record for the selected TreeView node in the Details View. I am using IDE : Visual Web Developer 2005 Express; OS=...
0
8269
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
8203
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
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
8642
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...
1
8368
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6125
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
5576
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();...
1
2630
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
1
1815
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.