473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1524
Hi,

Use contextmenu.show in the mousedown event.

Ken
-------------------
" A-PK" <pi********@hotmail.com> wrote in message
news:ua**************@tk2msftngp13.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***@bellsouth.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.public.dotnet.general,microsoft.public.d otnet.languages.vb,microso
ft.public.vstudio.development,microsoft.public.vst udio.generalNNTP-Posting-Host: adsl-18-39-198.mco.bellsouth.net 68.18.39.198
Path: cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11.
phx.gblXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:184878 microsoft.public.vstudio.development:4455
microsoft.public.vstudio.general:5658 microsoft.public.dotnet.general:126200X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,

Use contextmenu.show in the mousedown event.

Ken
-------------------
" A-PK" <pi********@hotmail.com> wrote in message
news:ua**************@tk2msftngp13.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@subtract_this_field.microsoft.com> wrote in
message news:XW*************@cpmsftngxa06.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***@bellsouth.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.public.dotnet.general,microsoft.public.d otnet.languages.vb,microso ft.public.vstudio.development,microsoft.public.vst udio.general
NNTP-Posting-Host: adsl-18-39-198.mco.bellsouth.net 68.18.39.198
Path:

cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11. phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:184878

microsoft.public.vstudio.development:4455
microsoft.public.vstudio.general:5658

microsoft.public.dotnet.general:126200
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,

Use contextmenu.show in the mousedown event.

Ken
-------------------
" A-PK" <pi********@hotmail.com> wrote in message
news:ua**************@tk2msftngp13.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_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown

Dim n As TreeNode

Dim myContextMenu As ContextMenu

If e.Button = MouseButtons.Right Then

Try

n = TreeView1.GetNodeAt(e.X, e.Y)

' figure out which menu to display

myContextMenu.Show(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********@hotmail.com> wrote in message
news:Ow*************@tk2msftngp13.phx.gbl...
my problem is how to detech which node that i click ?

"Francis Ingels [MSFT]" <ringels@subtract_this_field.microsoft.com> wrote in message news:XW*************@cpmsftngxa06.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***@bellsouth.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.public.dotnet.general,microsoft.public.d otnet.languages.vb,microso
ft.public.vstudio.development,microsoft.public.vst udio.general
NNTP-Posting-Host: adsl-18-39-198.mco.bellsouth.net 68.18.39.198
Path:

cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11.
phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:184878

microsoft.public.vstudio.development:4455
microsoft.public.vstudio.general:5658

microsoft.public.dotnet.general:126200
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,

Use contextmenu.show in the mousedown event.

Ken
-------------------
" A-PK" <pi********@hotmail.com> wrote in message
news:ua**************@tk2msftngp13.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.Right 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.Right 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***@bellsouth.net> schrieb im Newsbeitrag
news:u6**************@TK2MSFTNGP10.phx.gbl...
Hi,

Private Sub TreeView1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown

Dim n As TreeNode

Dim myContextMenu As ContextMenu

If e.Button = MouseButtons.Right Then

Try

n = TreeView1.GetNodeAt(e.X, e.Y)

' figure out which menu to display

myContextMenu.Show(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********@hotmail.com> wrote in message
news:Ow*************@tk2msftngp13.phx.gbl...
my problem is how to detech which node that i click ?

"Francis Ingels [MSFT]" <ringels@subtract_this_field.microsoft.com> wrote
in
message news:XW*************@cpmsftngxa06.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***@bellsouth.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.public.dotnet.general,microsoft.public.d otnet.languages.vb,microso
ft.public.vstudio.development,microsoft.public.vst udio.general
>NNTP-Posting-Host: adsl-18-39-198.mco.bellsouth.net 68.18.39.198
>Path:

cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11.
phx.gbl
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:184878 microsoft.public.vstudio.development:4455
microsoft.public.vstudio.general:5658

microsoft.public.dotnet.general:126200
>X-Tomcat-NG: microsoft.public.dotnet.languages.vb
>
>Hi,
>
> Use contextmenu.show in the mousedown event.
>
>Ken
>-------------------
>" A-PK" <pi********@hotmail.com> wrote in message
>news:ua**************@tk2msftngp13.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
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...
4
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...
2
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,...
3
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...
14
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
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");...
10
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...
8
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...
7
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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 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.