TreeNode location and ContextMenu

T

Tom W

I'm trying to show a ContextMenu when a user clicks on a TreeNode. Only
problem is setting the position of the ContextMenu, which I want to be
directly below the selected node. How do I get the location of the selected
node in a TreeView.

Thanks,
Tom
 
D

Daniel Moth

Good work...

For the benefit of the OP (or anybody with the same requirement), and as a
reminder for Microsoft may I add the following 2 comments:

1) Even after you show the context menu, if the user taps somewhere else and
loses the contextmenu, retapping on the node will not bring it up. This is
because AfterSelect does not fire for already selected nodes and I know of
no way to get the equivalent of NodeClick...

2) If as a result of a menuitem click (from the contextmenu shown) you wish
to show a form, then you will find the other form shown *behind* the main
one. The workaround is to use ShowDialog. Or instead of showing the
contextmenu direct, fire a thread and in its callback Invoke a method on the
gui thread to show the contextmenu.

Number 1 will apparently be rectified in CF 2.0 with
TreeView.NodeMouseClick. Alex I don't know if you have a workaround for this
(?)

Number 2 is a bug that I hope gets fixed in CF 2.0 More detail on it (inc.
repro steps and workaround) can be found here:
http://groups.google.com/groups?hl=...soft.public.dotnet.framework.compactframework

Cheers
Daniel
 
A

Alex Feinman [MVP]

---
Visit http://www.opennetcf.org
Daniel Moth said:
Good work...

For the benefit of the OP (or anybody with the same requirement), and as a
reminder for Microsoft may I add the following 2 comments:

1) Even after you show the context menu, if the user taps somewhere else and
loses the contextmenu, retapping on the node will not bring it up. This is
because AfterSelect does not fire for already selected nodes and I know of
no way to get the equivalent of NodeClick...

Number 1 will apparently be rectified in CF 2.0 with
TreeView.NodeMouseClick. Alex I don't know if you have a workaround for this
(?)


The only workaround I can think of of the top of my head is to use
OpenNETCF.ApplicationEx class and catch WM_LBUTTONDOWN. Then, using the same
technique as I shown to to hittest, find the clicked item and if it is
already selected, fire an AfterSelect even manually.
 
D

Daniel Moth

Thanks... I have considered using the ApplicationEx class a number of times
but have always hesitated because apparently there are unresolved issues
with apps showing modal dialogs and apparently there are performance hits
compared to the Application class... Having said that I have never tried it
myself.. If I do I'll post results here...

Cheers
Daniel
 
S

Serg Kuryata [MS]

Hi Daniel,

The issue #2 is a bug in the .NET Compact Framework. Thank you very much
for reporting it.

Best regards,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Daniel Moth" <[email protected]>
| References: <ZCwhc.180708$K91.448413@attbi_s02>
<[email protected]>
| Subject: Re: TreeNode location and ContextMenu
| Date: Thu, 22 Apr 2004 23:44:54 +0100
| Lines: 59
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: dsl-217-155-140-110.zen.co.uk 217.155.140.110
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
..phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:51555
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Good work...
|
| For the benefit of the OP (or anybody with the same requirement), and as a
| reminder for Microsoft may I add the following 2 comments:
|
| 1) Even after you show the context menu, if the user taps somewhere else
and
| loses the contextmenu, retapping on the node will not bring it up. This is
| because AfterSelect does not fire for already selected nodes and I know of
| no way to get the equivalent of NodeClick...
|
| 2) If as a result of a menuitem click (from the contextmenu shown) you
wish
| to show a form, then you will find the other form shown *behind* the main
| one. The workaround is to use ShowDialog. Or instead of showing the
| contextmenu direct, fire a thread and in its callback Invoke a method on
the
| gui thread to show the contextmenu.
|
| Number 1 will apparently be rectified in CF 2.0 with
| TreeView.NodeMouseClick. Alex I don't know if you have a workaround for
this
| (?)
|
| Number 2 is a bug that I hope gets fixed in CF 2.0 More detail on it (inc.
| repro steps and workaround) can be found here:
|
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=TreeView.After
Select+ContextMenu.Show&meta=group%3Dmicrosoft.public.dotnet.framework.compa
ctframework
|
| Cheers
| Daniel
|
|
| | > You need to use a bit of PInvoke. I've put together a sample for you at
| > http://www.alexfeinman.com/download.asp?doc=TreeViewNode.zip
| > It demonstrates how to get the location of the selected node (provided
| that
| > it is selected with a stylus) and pop up a context menu
| >
| > --
| > Alex Feinman
| > ---
| > Visit http://www.opennetcf.org
| >
| > | > > I'm trying to show a ContextMenu when a user clicks on a TreeNode.
Only
| > > problem is setting the position of the ContextMenu, which I want to be
| > > directly below the selected node. How do I get the location of the
| > selected
| > > node in a TreeView.
| > >
| > > Thanks,
| > > Tom
| > >
| > >
| >
| >
|
|
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top