Bug in TreeView

F

Frank Lamers

Hello,

I am running into an error in the TreeView control and look for a
workaround. Has anyone an idea? I used VB.NET for my program.

The Bug:
* System.Windows.Forms.TreeView after calling .Clear the property
..SelectedNode is still set
When clearing the TreeView the SelectedNode is still set to a node.
* System.Windows.Forms.TreeView.SelectedNode cannot be set
The SelectedNode property cannot be set manually - neither to a node nor to
nothing (VB.NET)

How can I avoid this problem?





Other question:
Does anybody know if there will be a ServicePack for the CF in a short
range?
I found some more bugs and it is very time consuming to look for
workarounds.

Some of the bugs i found:
* XmlDocument.CreateNode(XmlNodeType, String, String) ignores second
parameter for comment and CDATA nodes
* XmlDocument.CreateNode(XmlNodeType, String, String) specifying a namespace
as third parameter creating an element node will set the namespaceURI, but
no 'xmlns' attribute is added (after save and load the attribute exists)
* XmlDocument.CreateNode(XmlNodeType, String, String) creating an attribute
node and specifying a namespace sets no prefix, but adds automatically a
prefix in the XmlNode.OuterXml property (i.e. d0p1). The
XmlDocument.OuterXml gives a different prefix (i.e. d2p1)
* XmlDocument.CreateNode(XmlNodeType, String, String) creating an attribute
node always throws exception if second parameter is 'xmlns' (illegal
namespace)
* XmlDocument.CreateAttribut(String, String) same behavior as using
CreateNode for attribute node
* XmlDocument.CreateAttribut(String) with qualified name (ns:name) sets the
name qualified, but the OuterXml property just uses the localname without
prefix. Prefix gets lost during save.
* XmlDocument.CreateNode(XmlNodeType, String, String) with qualified name
(ns:name) sets the name qualified, but the OuterXml property just uses the
localname without prefix. Prefix gets lost during save.
* System.Windows.Forms.TreeView after calling .Clear the property
..SelectedNode is still set
* System.Windows.Forms.TreeView.SelectedNode cannot be set


--Frank
 
P

Peter Foot [MVP]

What version of the Compact Framework runtime are you using? the original
RTM, SP1 or SP2?

With regards the second point I have used code to assign a node to the
SelectedNode property which works fine, can you post the code you're having
trouble with. The Node you assign must have been added to the tree prior to
selecting it.

Peter
 
F

Frank Lamers

Hi Peter,

I can I determine the version of CF installed on my PocketPC?
Nevertheless I tried my code after allying SP1 and SP2 and the error was
still there. Here some code to show you the problem:

Dim tv As New TreeView
Dim tn As TreeNode
tn = tv.Nodes.Add("newnode")
tv.SelectedNode = tn
if tv.SelectedNode = tn then
MsgBox ("Successful")
Else
MsgBox ("!!! Error")
End If
tv.SelectedNode = Nothing

Any Idea?

Regards
--Frank
 
D

David So [MSFT]

This is a know bug in NetCF v1 and it is fixed in v2. The cause is because
treeview is caching the selected node. Unfortunately, the selected node can
change without the treeview notifying the selectednode, the work around
would be to set the treeview.SelectedNode to Null whenever you call
treeView.Nodes.Clear()

David
This posting is provided "AS IS" with no warranties, and confers no rights.
 
F

Frank Lamers

I have applied SP2 and it seemed to be successful. But the problem still
exists.
How do I check the version of the CF on the device?
And how do I apply the SP to the emulator of VisualStudio?

I made some more tests and encircled the problem a little bit.

1.
If you call Treeview.Nodes.Clear the Treeview is cleared, but the Property
SelectedNode is set to the former last (!) node (which now is not anymore
part of the treeview). The Fullpath of the SelectedNode shows a message that
there was an System.Exception.

2. After you called Clear you cannot set the SelectedNode to nothing (or any
other of nthe former nodes)! If you add new nodes to the TreeView, then you
can set SelectedNode to these. To workaround this bug you have to set
SelectedNode to nothing BEFORE you clear all nodes.

I used .NET CF with applied SP2 and programmed in VB.NET

Sample code: (create a treeview first)
Dim tn As TreeNode
tn = TreeView1.Nodes.Add("Newnode")
TreeView1.SelectedNode = tn
TreeView1.Nodes.Clear()
'!!! Treeview1.SelectedNode is still pointing to a treenode
MsgBox("SelectedNode:" & TreeView1.SelectedNode.Text)
'Set to nothing manually fails
TreeView1.SelectedNode = Nothing
If TreeView1.SelectedNode Is Nothing Then
MsgBox("manually set to nothing")
Else
MsgBox("!!! cannot set to nothing")
End If

--Frank
 
J

Joe Bork [MSFT]

Hello Frank,

You can tell the version of NetCF running on the device or emulator by
using the Cgacutil program. See this entry in the FAQ for details:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/faq/default.a
spx#1.26

You can get SP2 installed on the emulator by copying the X86 SP2 CAB file
to the emulator and exploding it there. We unfortunately don't have a
supported solution for updating Visual Studio .NET 2003 so that SP2 is used
during F5 deployment. (There may be ways to achieve this, but they leave
the VS product in an unknown state with respect to setup.) One technique
you can use to get the right CAB to the device is to place it on a web site
and browse to the CAB file on the emulator in Pocket IE.

As to your point #2 below, you are correct that the workaround for pre-SP2
builds is to set the SelectedNode to null (or Nothing) before clearing the
TreeView control.

--Joe

--
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Frank Lamers" <nomail>
| Subject: Re: Bug in TreeView
| Date: Thu, 26 Feb 2004 11:10:58 +0100
|
| I have applied SP2 and it seemed to be successful. But the problem still
| exists.
| How do I check the version of the CF on the device?
| And how do I apply the SP to the emulator of VisualStudio?
|
| I made some more tests and encircled the problem a little bit.
|
| 1.
| If you call Treeview.Nodes.Clear the Treeview is cleared, but the Property
| SelectedNode is set to the former last (!) node (which now is not anymore
| part of the treeview). The Fullpath of the SelectedNode shows a message
that
| there was an System.Exception.
|
| 2. After you called Clear you cannot set the SelectedNode to nothing (or
any
| other of nthe former nodes)! If you add new nodes to the TreeView, then
you
| can set SelectedNode to these. To workaround this bug you have to set
| SelectedNode to nothing BEFORE you clear all nodes.
|
| I used .NET CF with applied SP2 and programmed in VB.NET
|
| Sample code: (create a treeview first)
| Dim tn As TreeNode
| tn = TreeView1.Nodes.Add("Newnode")
| TreeView1.SelectedNode = tn
| TreeView1.Nodes.Clear()
| '!!! Treeview1.SelectedNode is still pointing to a treenode
| MsgBox("SelectedNode:" & TreeView1.SelectedNode.Text)
| 'Set to nothing manually fails
| TreeView1.SelectedNode = Nothing
| If TreeView1.SelectedNode Is Nothing Then
| MsgBox("manually set to nothing")
| Else
| MsgBox("!!! cannot set to nothing")
| End If
|
| --Frank
|
|
| | > This is a know bug in NetCF v1 and it is fixed in v2. The cause is
because
| > treeview is caching the selected node. Unfortunately, the selected node
| can
| > change without the treeview notifying the selectednode, the work around
| > would be to set the treeview.SelectedNode to Null whenever you call
| > treeView.Nodes.Clear()
| >
| > David
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| >
|
|
|
 
F

Frank Lamers

Hi Joe,

thanks for the answer.

The bug still occurs after applying SP2 (checked with Cgacutil).
See my new posting where I document some more bugs I found.

Deploying the cab of SP2 to the emulator is much easier than placing it on a
website. Just add the cab file as an existing item to your solution in VS.
Then it is copied during deployment to the emulator and you just have to
start it.
 

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