PC Review


Reply
Thread Tools Rate Thread

Bug in TreeView

 
 
Frank Lamers
Guest
Posts: n/a
 
      19th Feb 2004
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


 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      19th Feb 2004
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

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

"Frank Lamers" <nomail> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Frank Lamers
Guest
Posts: n/a
 
      23rd Feb 2004
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


"Peter Foot [MVP]" <(E-Mail Removed)> wrote in message
news:ume$(E-Mail Removed)...
> 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
>
> --
> Peter Foot
> Windows Embedded MVP
> OpenNETCF.org Senior Advisor
> www.inthehand.com | www.opennetcf.org
>
> "Frank Lamers" <nomail> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
David So [MSFT]
Guest
Posts: n/a
 
      26th Feb 2004
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.


 
Reply With Quote
 
Frank Lamers
Guest
Posts: n/a
 
      26th Feb 2004
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


"David So [MSFT]" <(E-Mail Removed)> wrote in message
news:yybXUkA$(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
Joe Bork [MSFT]
Guest
Posts: n/a
 
      8th Mar 2004
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/p.../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
|
|
| "David So [MSFT]" <(E-Mail Removed)> wrote in message
| news:yybXUkA$(E-Mail Removed)...
| > 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.
| >
| >
|
|
|

 
Reply With Quote
 
Frank Lamers
Guest
Posts: n/a
 
      10th Mar 2004
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.


"Joe Bork [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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/p.../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
> |
> |
> | "David So [MSFT]" <(E-Mail Removed)> wrote in message
> | news:yybXUkA$(E-Mail Removed)...
> | > 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.
> | >
> | >
> |
> |
> |
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recreate a >>C# WinForms<< TreeView "state" -after- treeview rebuild ?? Any TreeView GODS out there ?? frostbb Microsoft C# .NET 6 18th Aug 2008 05:08 PM
HOW TO: Treeview, obtain the first node index in a sorted Treeview =?Utf-8?B?S2V2aW4gTWNDYXJ0bmV5?= Microsoft Access Form Coding 5 21st Aug 2007 04:16 PM
HOW TO: Treeview, obtain the first node index in a sorted Treeview =?Utf-8?B?S2V2aW4gTWNDYXJ0bmV5?= Microsoft Access Forms 0 20th Aug 2007 06:52 PM
Generate treeview in server manipulate treeview in client side Ravi Microsoft Dot NET 0 2nd Sep 2004 04:00 PM
Re: TreeView, TreeView.HideSelection=false, Window.Minimize NotYetaNurd Microsoft Dot NET Framework Forms 2 30th Jun 2003 06:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:18 AM.