Treeview Click Event

Does anyone have a good solution to the Click Event for the Treeview control in .Net Compact Framework? Any third-party control suggestions? (I'm using VB.NET)

I am currently using AfterSelect event, as prescribed by Microsoft and many others. However, when I click a node, I open a new form based on the node I clicked. When the form closes, it updates the treeview control, which causes the AfterSelect event to fire again and reopen the form. Also, once selected, you cannot select the same node again unless you move off it and back on it. In my case, causing a new form to open when moving off it.

In addition, I build the contents of the treeview dynamically, and have occasion to have only one node in the tree, and it is rendered useless because the node I wish to select is already selected.

I don't understand why such an important event would have been left out of this control, and also in the Listview, in CF. And from what I have read, it will be left out again in VS 2005, despite requests from beta users for its inclusion.

[1049 byte] By [unit107] at [2007-12-16]
# 1

With netcf 2.0 it is possible to subclass (in the win32 sense) controls using managed code.

Examples are here (in fact offering exactly what you want):
http://blogs.msdn.com/netcfteam/archive/2005/05/20/420551.aspx

..and here:
http://blog.opennetcf.org/ayakhnin/PermaLink.aspx?guid=eacd2a5f-a7fb-4bce-9336-f974ea2d2e29

Cheers
Daniel

DanielMoth at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2
Unfortunately, I am using .NET 2003 (CF 1.1). This will not work for me.

I gather that there is no way to raise any event that will provide a simulated "Click" event, other than the AfterSelected event. It seems that any mouse activity is not available, and GetNodeAt(pt) method is also not available anyway.

For my purposes, I will have to go with a treeview and a button to launch a new form, based on the node selected to prevent the aforementioned behavior, which is an completely unnecessary mouse click. But since our friends at MS decided "Click" or "NodeClick" was not important to bring forward from eVB, what choice do I have?

Again, Does anyone know of any third part CF 1.1 treeview control that will allow for a "Click" behavior without the same headaches as the stock Treeview control?

unit107 at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3

Unfortunately with v1.0 you have no realistic solution other than to workaround (with a button as you say or a menu item or whatever). I sympathize with your requirement and have submitted a request for NodeClick in the past:
http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=8bb0f504-037b-4c81-aea0-dfcd25185a43


If you really most positively wanted to achieve this you could invest the time in writing a native dll for subclassing the TreeView control after obtaining its handle (or use ApplicationEx from opennetcf) and catch the LBUTTONDOWN message and then use HitTest to get which node it is and then deal with it. This is more hassle than it is worth in my opinion so I've never done it myself.

Cheers
Daniel

DanielMoth at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...