|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
XML document in a treevie needs 57secodnsCant believe it:
Loading an XML document (150kb) in a treeview using .net 2.0 using 2.0 seconds!!! That is unusable!!! Loading the same document in Iexplore, it needs 1/100 of a second That could not be .net That is incredible, and non usable. What in the hell do ms wasting the time... regards remo Mhh... interesting.
Out of curiosity, why do you write slow code? Show quote "remo" <brig***@onlinepansystem.ch> wrote in message news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... > Cant believe it: > Loading an XML document (150kb) in a treeview using .net 2.0 using 2.0 > seconds!!! > That is unusable!!! > Loading the same document in Iexplore, it needs 1/100 of a second > That could not be .net > That is incredible, and non usable. > What in the hell do ms wasting the time... > > regards remo > > Not my code is slow!
MS code is slow! .... Show quote "Lloyd Dupont" <net.galador@ld> wrote in message news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... > Mhh... interesting. > Out of curiosity, why do you write slow code? > > "remo" <brig***@onlinepansystem.ch> wrote in message > news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >> Cant believe it: >> Loading an XML document (150kb) in a treeview using .net 2.0 using 2.0 >> seconds!!! >> That is unusable!!! >> Loading the same document in Iexplore, it needs 1/100 of a second >> That could not be .net >> That is incredible, and non usable. >> What in the hell do ms wasting the time... >> >> regards remo >> >> > > remo wrote:
> Not my code is slow! If you're interested in learning why your code is slow, it would help a > MS code is slow! great deal if you'd post an example of how you're "loading an XML document in a treeview". If your interest is only in complaining, then you've accomplished your goal already. -cd Send some sample code and somebody might find an answer.
remo wrote: Show quote > Not my code is slow! > MS code is slow! > ... > > > > "Lloyd Dupont" <net.galador@ld> wrote in message > news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... >> Mhh... interesting. >> Out of curiosity, why do you write slow code? >> >> "remo" <brig***@onlinepansystem.ch> wrote in message >> news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >>> Cant believe it: >>> Loading an XML document (150kb) in a treeview using .net 2.0 using 2.0 >>> seconds!!! >>> That is unusable!!! >>> Loading the same document in Iexplore, it needs 1/100 of a second >>> That could not be .net >>> That is incredible, and non usable. >>> What in the hell do ms wasting the time... >>> >>> regards remo >>> >>> >> > > Hello
The code is copied from MSDN here is the link: Knowledge Base: How to populate a treeview control with XML data in Visual C# 2005 or in visual C# .NET ms-help://MS.VSCC.v80/MS.MSDN.vAug06.en/enu_kbnetframeworkkb/netframeworkkb/317597.htm Running on a Dell Inspiron 9400 dualcore, with 2GB Ram Intel CPU T2400 @1.83GHz Using VisualStudio 2005 and C# The XML File is 158kb and has the folowing structure: <Root> <sz> x="1.1" y=1.1</sz> <mx> x="1" y=1</mx> <dm> <dc x="1" y="1"/> <op x="1.1" y="1.1"/> <fp x="1.1" y="1.1"/> <fs x="1.1" y="1.1"/> <fr x="1.1"/> <dv> <bpc x="1"/> <op x="1.1" y="1.1"/> <fp x="1.1" y="1.1"/> <fs x="1.1" y="1.1"/> <fr x="1.1"/> <bp> <op x="1.1" y="1.1"/> <fp x="1.1" y="1.1"/> <fs x="1.1" y="1.1"/> <fr x="1.1"/> <Req x="1"> <st>1</st> </bp> </dv> </dm> </Root> This is only the structure, the names are 10..15char's long The attributes "1.0" are floats The "1" are integer values Each dm contains 64 dv's Each dv contains one bp There are 4 dm's and 64 dv's in one dm: 256 dv's and 256 bp's Loading the XML DOM using about 40ms ... 500ms Loading the tree using about 55..58s regards remo Show quote "Yves. L." <Yv***@discussions.microsoft.com> wrote in message news:u4%23DDIrIHHA.536@TK2MSFTNGP02.phx.gbl... > Send some sample code and somebody might find an answer. > > > remo wrote: >> Not my code is slow! >> MS code is slow! >> ... >> >> >> >> "Lloyd Dupont" <net.galador@ld> wrote in message >> news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... >>> Mhh... interesting. >>> Out of curiosity, why do you write slow code? >>> >>> "remo" <brig***@onlinepansystem.ch> wrote in message >>> news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >>>> Cant believe it: >>>> Loading an XML document (150kb) in a treeview using .net 2.0 using 2.0 >>>> seconds!!! >>>> That is unusable!!! >>>> Loading the same document in Iexplore, it needs 1/100 of a second >>>> That could not be .net >>>> That is incredible, and non usable. >>>> What in the hell do ms wasting the time... >>>> >>>> regards remo >>>> >>>> >>> >> Hi,
I've tried the sample of the KB with a bigger XMl file (about 100 KB) and it is indeed sloooooow. Now depending on what you want to achieve you have different strategies you can apply : 1/ Lazy creation : create only the the first n-levels of node that you want to display and create a dummy child node where necessary I the click event of your node, if the child nodes is a dummy then create the real child node 2/ load and create your treeview in a seperate thread. YvesL remo wrote: Show quote > Hello > The code is copied from MSDN here is the link: > > Knowledge Base: > How to populate a treeview control with XML data in Visual C# 2005 or > in visual C# .NET > > > ms-help://MS.VSCC.v80/MS.MSDN.vAug06.en/enu_kbnetframeworkkb/netframeworkkb/317597.htm > > Running on a Dell Inspiron 9400 dualcore, with 2GB Ram > Intel CPU T2400 @1.83GHz > > Using VisualStudio 2005 and C# > The XML File is 158kb and has the folowing structure: > <Root> > <sz> x="1.1" y=1.1</sz> > <mx> x="1" y=1</mx> > <dm> > <dc x="1" y="1"/> > <op x="1.1" y="1.1"/> > <fp x="1.1" y="1.1"/> > <fs x="1.1" y="1.1"/> > <fr x="1.1"/> > <dv> > <bpc x="1"/> > <op x="1.1" y="1.1"/> > <fp x="1.1" y="1.1"/> > <fs x="1.1" y="1.1"/> > <fr x="1.1"/> > <bp> > <op x="1.1" y="1.1"/> > <fp x="1.1" y="1.1"/> > <fs x="1.1" y="1.1"/> > <fr x="1.1"/> > <Req x="1"> > <st>1</st> > </bp> > </dv> > </dm> > </Root> > This is only the structure, the names are 10..15char's long > The attributes "1.0" are floats > The "1" are integer values > > Each dm contains 64 dv's > Each dv contains one bp > There are 4 dm's and 64 dv's in one dm: 256 dv's and 256 bp's > > Loading the XML DOM using about 40ms ... 500ms > Loading the tree using about 55..58s > > regards remo > > > > > > "Yves. L." <Yv***@discussions.microsoft.com> wrote in message > news:u4%23DDIrIHHA.536@TK2MSFTNGP02.phx.gbl... >> Send some sample code and somebody might find an answer. >> >> >> remo wrote: >>> Not my code is slow! >>> MS code is slow! >>> ... >>> >>> >>> >>> "Lloyd Dupont" <net.galador@ld> wrote in message >>> news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... >>>> Mhh... interesting. >>>> Out of curiosity, why do you write slow code? >>>> >>>> "remo" <brig***@onlinepansystem.ch> wrote in message >>>> news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >>>>> Cant believe it: >>>>> Loading an XML document (150kb) in a treeview using .net 2.0 using 2.0 >>>>> seconds!!! >>>>> That is unusable!!! >>>>> Loading the same document in Iexplore, it needs 1/100 of a second >>>>> That could not be .net >>>>> That is incredible, and non usable. >>>>> What in the hell do ms wasting the time... >>>>> >>>>> regards remo >>>>> >>>>> > Hi
The first one I can do, but it needs much more logic.... The second I can also do, but the time will not be shorter to load the tree .... (not realy a solution) Would be a C++ implementation with .NET faster? regards remo Show quote "Yves. L." <Yv***@discussions.microsoft.com> wrote in message news:eWyhbc1IHHA.1248@TK2MSFTNGP03.phx.gbl... > Hi, > I've tried the sample of the KB with a bigger XMl file (about 100 KB) and > it is indeed sloooooow. > > Now depending on what you want to achieve you have different strategies > you can apply : > 1/ Lazy creation : create only the the first n-levels of node that you > want to display and create a dummy child node where necessary > I the click event of your node, if the child nodes is a dummy then create > the real child node > > 2/ load and create your treeview in a seperate thread. > > YvesL > remo wrote: >> Hello >> The code is copied from MSDN here is the link: >> >> Knowledge Base: >> How to populate a treeview control with XML data in Visual C# 2005 >> or in visual C# .NET >> >> >> ms-help://MS.VSCC.v80/MS.MSDN.vAug06.en/enu_kbnetframeworkkb/netframeworkkb/317597.htm >> >> Running on a Dell Inspiron 9400 dualcore, with 2GB Ram >> Intel CPU T2400 @1.83GHz >> >> Using VisualStudio 2005 and C# >> The XML File is 158kb and has the folowing structure: >> <Root> >> <sz> x="1.1" y=1.1</sz> >> <mx> x="1" y=1</mx> >> <dm> >> <dc x="1" y="1"/> >> <op x="1.1" y="1.1"/> >> <fp x="1.1" y="1.1"/> >> <fs x="1.1" y="1.1"/> >> <fr x="1.1"/> >> <dv> >> <bpc x="1"/> >> <op x="1.1" y="1.1"/> >> <fp x="1.1" y="1.1"/> >> <fs x="1.1" y="1.1"/> >> <fr x="1.1"/> >> <bp> >> <op x="1.1" y="1.1"/> >> <fp x="1.1" y="1.1"/> >> <fs x="1.1" y="1.1"/> >> <fr x="1.1"/> >> <Req x="1"> >> <st>1</st> >> </bp> >> </dv> >> </dm> >> </Root> >> This is only the structure, the names are 10..15char's long >> The attributes "1.0" are floats >> The "1" are integer values >> >> Each dm contains 64 dv's >> Each dv contains one bp >> There are 4 dm's and 64 dv's in one dm: 256 dv's and 256 bp's >> >> Loading the XML DOM using about 40ms ... 500ms >> Loading the tree using about 55..58s >> >> regards remo >> >> >> >> >> >> "Yves. L." <Yv***@discussions.microsoft.com> wrote in message >> news:u4%23DDIrIHHA.536@TK2MSFTNGP02.phx.gbl... >>> Send some sample code and somebody might find an answer. >>> >>> >>> remo wrote: >>>> Not my code is slow! >>>> MS code is slow! >>>> ... >>>> >>>> >>>> >>>> "Lloyd Dupont" <net.galador@ld> wrote in message >>>> news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... >>>>> Mhh... interesting. >>>>> Out of curiosity, why do you write slow code? >>>>> >>>>> "remo" <brig***@onlinepansystem.ch> wrote in message >>>>> news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >>>>>> Cant believe it: >>>>>> Loading an XML document (150kb) in a treeview using .net 2.0 using >>>>>> 2.0 seconds!!! >>>>>> That is unusable!!! >>>>>> Loading the same document in Iexplore, it needs 1/100 of a second >>>>>> That could not be .net >>>>>> That is incredible, and non usable. >>>>>> What in the hell do ms wasting the time... >>>>>> >>>>>> regards remo >>>>>> >>>>>> >> Hello again,
> Hi Yes more code, but if it solves your problem...> The first one I can do, but it needs much more logic.... > The second I can also do, but the time will not be shorter to load the tree Time would indeed not be shorter, but your UI would be responsive.> ... > (not realy a solution) I don't really known. I guess not if you would use managed C++ .> > Would be a C++ implementation with .NET faster? Otherwise that would mean creating your complete UI in C++ , or just the tree control in C++. I would go for #1 seems the easiest an simplest way. Yves I don't have this article....
Anyway IF you purpose is to improve the speed of this operation I could suggest a couple of things. Show quote "remo" <brig***@onlinepansystem.ch> wrote in message news:%23ZY9Hg0IHHA.1816@TK2MSFTNGP06.phx.gbl... > Hello > The code is copied from MSDN here is the link: > > Knowledge Base: > How to populate a treeview control with XML data in Visual C# 2005 or > in visual C# .NET > > > ms-help://MS.VSCC.v80/MS.MSDN.vAug06.en/enu_kbnetframeworkkb/netframeworkkb/317597.htm > > Running on a Dell Inspiron 9400 dualcore, with 2GB Ram > Intel CPU T2400 @1.83GHz > > Using VisualStudio 2005 and C# > The XML File is 158kb and has the folowing structure: > <Root> > <sz> x="1.1" y=1.1</sz> > <mx> x="1" y=1</mx> > <dm> > <dc x="1" y="1"/> > <op x="1.1" y="1.1"/> > <fp x="1.1" y="1.1"/> > <fs x="1.1" y="1.1"/> > <fr x="1.1"/> > <dv> > <bpc x="1"/> > <op x="1.1" y="1.1"/> > <fp x="1.1" y="1.1"/> > <fs x="1.1" y="1.1"/> > <fr x="1.1"/> > <bp> > <op x="1.1" y="1.1"/> > <fp x="1.1" y="1.1"/> > <fs x="1.1" y="1.1"/> > <fr x="1.1"/> > <Req x="1"> > <st>1</st> > </bp> > </dv> > </dm> > </Root> > This is only the structure, the names are 10..15char's long > The attributes "1.0" are floats > The "1" are integer values > > Each dm contains 64 dv's > Each dv contains one bp > There are 4 dm's and 64 dv's in one dm: 256 dv's and 256 bp's > > Loading the XML DOM using about 40ms ... 500ms > Loading the tree using about 55..58s > > regards remo > > > > > > "Yves. L." <Yv***@discussions.microsoft.com> wrote in message > news:u4%23DDIrIHHA.536@TK2MSFTNGP02.phx.gbl... >> Send some sample code and somebody might find an answer. >> >> >> remo wrote: >>> Not my code is slow! >>> MS code is slow! >>> ... >>> >>> >>> >>> "Lloyd Dupont" <net.galador@ld> wrote in message >>> news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... >>>> Mhh... interesting. >>>> Out of curiosity, why do you write slow code? >>>> >>>> "remo" <brig***@onlinepansystem.ch> wrote in message >>>> news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >>>>> Cant believe it: >>>>> Loading an XML document (150kb) in a treeview using .net 2.0 using 2.0 >>>>> seconds!!! >>>>> That is unusable!!! >>>>> Loading the same document in Iexplore, it needs 1/100 of a second >>>>> That could not be .net >>>>> That is incredible, and non usable. >>>>> What in the hell do ms wasting the time... >>>>> >>>>> regards remo >>>>> >>>>> >>>> >>> > Hi
Yes please let me know about... Thanks and regards remo Show quote "Lloyd Dupont" <net.galador@ld> wrote in message news:%23mtb0o1IHHA.1240@TK2MSFTNGP03.phx.gbl... >I don't have this article.... > Anyway IF you purpose is to improve the speed of this operation > I could suggest a couple of things. > > "remo" <brig***@onlinepansystem.ch> wrote in message > news:%23ZY9Hg0IHHA.1816@TK2MSFTNGP06.phx.gbl... >> Hello >> The code is copied from MSDN here is the link: >> >> Knowledge Base: >> How to populate a treeview control with XML data in Visual C# 2005 >> or in visual C# .NET >> >> >> ms-help://MS.VSCC.v80/MS.MSDN.vAug06.en/enu_kbnetframeworkkb/netframeworkkb/317597.htm >> >> Running on a Dell Inspiron 9400 dualcore, with 2GB Ram >> Intel CPU T2400 @1.83GHz >> >> Using VisualStudio 2005 and C# >> The XML File is 158kb and has the folowing structure: >> <Root> >> <sz> x="1.1" y=1.1</sz> >> <mx> x="1" y=1</mx> >> <dm> >> <dc x="1" y="1"/> >> <op x="1.1" y="1.1"/> >> <fp x="1.1" y="1.1"/> >> <fs x="1.1" y="1.1"/> >> <fr x="1.1"/> >> <dv> >> <bpc x="1"/> >> <op x="1.1" y="1.1"/> >> <fp x="1.1" y="1.1"/> >> <fs x="1.1" y="1.1"/> >> <fr x="1.1"/> >> <bp> >> <op x="1.1" y="1.1"/> >> <fp x="1.1" y="1.1"/> >> <fs x="1.1" y="1.1"/> >> <fr x="1.1"/> >> <Req x="1"> >> <st>1</st> >> </bp> >> </dv> >> </dm> >> </Root> >> This is only the structure, the names are 10..15char's long >> The attributes "1.0" are floats >> The "1" are integer values >> >> Each dm contains 64 dv's >> Each dv contains one bp >> There are 4 dm's and 64 dv's in one dm: 256 dv's and 256 bp's >> >> Loading the XML DOM using about 40ms ... 500ms >> Loading the tree using about 55..58s >> >> regards remo >> >> >> >> >> >> "Yves. L." <Yv***@discussions.microsoft.com> wrote in message >> news:u4%23DDIrIHHA.536@TK2MSFTNGP02.phx.gbl... >>> Send some sample code and somebody might find an answer. >>> >>> >>> remo wrote: >>>> Not my code is slow! >>>> MS code is slow! >>>> ... >>>> >>>> >>>> >>>> "Lloyd Dupont" <net.galador@ld> wrote in message >>>> news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... >>>>> Mhh... interesting. >>>>> Out of curiosity, why do you write slow code? >>>>> >>>>> "remo" <brig***@onlinepansystem.ch> wrote in message >>>>> news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >>>>>> Cant believe it: >>>>>> Loading an XML document (150kb) in a treeview using .net 2.0 using >>>>>> 2.0 seconds!!! >>>>>> That is unusable!!! >>>>>> Loading the same document in Iexplore, it needs 1/100 of a second >>>>>> That could not be .net >>>>>> That is incredible, and non usable. >>>>>> What in the hell do ms wasting the time... >>>>>> >>>>>> regards remo >>>>>> >>>>>> >>>>> >>>> >> > > As I don't have the code (nor the required MSDN version, it seems) I could
suggest 2 things (without knowing how relevant they are): 1. I will create all the node without attaching them to a TreeView. When all the node would have been created I will add the top level ones to the TreeView. This way you minismize your calls to the TreeView class. Which is a performance bottleneck as all WinForm control which are think wrapper around win32 controls (such as the treeview) don't behave well. 2. I will go on www.codeproject.com and use one of their fully managed TreeView class/sample. Which would probably behave much better the the one in the framework.... Show quote "remo" <brig***@onlinepansystem.ch> wrote in message news:%23cMB5r1IHHA.1276@TK2MSFTNGP04.phx.gbl... > Hi > Yes please let me know about... > > Thanks and regards remo > > "Lloyd Dupont" <net.galador@ld> wrote in message > news:%23mtb0o1IHHA.1240@TK2MSFTNGP03.phx.gbl... >>I don't have this article.... >> Anyway IF you purpose is to improve the speed of this operation >> I could suggest a couple of things. >> >> "remo" <brig***@onlinepansystem.ch> wrote in message >> news:%23ZY9Hg0IHHA.1816@TK2MSFTNGP06.phx.gbl... >>> Hello >>> The code is copied from MSDN here is the link: >>> >>> Knowledge Base: >>> How to populate a treeview control with XML data in Visual C# 2005 >>> or in visual C# .NET >>> >>> >>> ms-help://MS.VSCC.v80/MS.MSDN.vAug06.en/enu_kbnetframeworkkb/netframeworkkb/317597.htm >>> >>> Running on a Dell Inspiron 9400 dualcore, with 2GB Ram >>> Intel CPU T2400 @1.83GHz >>> >>> Using VisualStudio 2005 and C# >>> The XML File is 158kb and has the folowing structure: >>> <Root> >>> <sz> x="1.1" y=1.1</sz> >>> <mx> x="1" y=1</mx> >>> <dm> >>> <dc x="1" y="1"/> >>> <op x="1.1" y="1.1"/> >>> <fp x="1.1" y="1.1"/> >>> <fs x="1.1" y="1.1"/> >>> <fr x="1.1"/> >>> <dv> >>> <bpc x="1"/> >>> <op x="1.1" y="1.1"/> >>> <fp x="1.1" y="1.1"/> >>> <fs x="1.1" y="1.1"/> >>> <fr x="1.1"/> >>> <bp> >>> <op x="1.1" y="1.1"/> >>> <fp x="1.1" y="1.1"/> >>> <fs x="1.1" y="1.1"/> >>> <fr x="1.1"/> >>> <Req x="1"> >>> <st>1</st> >>> </bp> >>> </dv> >>> </dm> >>> </Root> >>> This is only the structure, the names are 10..15char's long >>> The attributes "1.0" are floats >>> The "1" are integer values >>> >>> Each dm contains 64 dv's >>> Each dv contains one bp >>> There are 4 dm's and 64 dv's in one dm: 256 dv's and 256 bp's >>> >>> Loading the XML DOM using about 40ms ... 500ms >>> Loading the tree using about 55..58s >>> >>> regards remo >>> >>> >>> >>> >>> >>> "Yves. L." <Yv***@discussions.microsoft.com> wrote in message >>> news:u4%23DDIrIHHA.536@TK2MSFTNGP02.phx.gbl... >>>> Send some sample code and somebody might find an answer. >>>> >>>> >>>> remo wrote: >>>>> Not my code is slow! >>>>> MS code is slow! >>>>> ... >>>>> >>>>> >>>>> >>>>> "Lloyd Dupont" <net.galador@ld> wrote in message >>>>> news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... >>>>>> Mhh... interesting. >>>>>> Out of curiosity, why do you write slow code? >>>>>> >>>>>> "remo" <brig***@onlinepansystem.ch> wrote in message >>>>>> news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >>>>>>> Cant believe it: >>>>>>> Loading an XML document (150kb) in a treeview using .net 2.0 using >>>>>>> 2.0 seconds!!! >>>>>>> That is unusable!!! >>>>>>> Loading the same document in Iexplore, it needs 1/100 of a second >>>>>>> That could not be .net >>>>>>> That is incredible, and non usable. >>>>>>> What in the hell do ms wasting the time... >>>>>>> >>>>>>> regards remo >>>>>>> >>>>>>> >>>>>> >>>>> >>> >> >> > > Thanks for the info.
I think then we can not use the .Net as tool for our programm So slow code, this is a very big risk.... Here is the code just for information: private void AddNode(XmlNode inXmlNode, TreeNode inTreeNode) { XmlNode xNode; TreeNode tNode; XmlNodeList nodeList; int i; // Loop through the XML nodes until the leaf is reached. // Add the nodes to the TreeView during the looping process. if (inXmlNode.HasChildNodes) { nodeList = inXmlNode.ChildNodes; for (i = 0; i <= nodeList.Count - 1; i++) { xNode = inXmlNode.ChildNodes[i]; inTreeNode.Nodes.Add(new TreeNode(xNode.Name)); tNode = inTreeNode.Nodes[i]; AddNode(xNode, tNode); } } else { // Here you need to pull the data from the XmlNode based on the // type of node, whether attribute values are required, and so forth. inTreeNode.Text = (inXmlNode.OuterXml).Trim(); } } private void loadFileToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; System.IO.Stream myStream = null; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { treeView1.Nodes.Clear(); if ((myStream = openFileDialog1.OpenFile()) != null) { using (myStream) { try { DateTime BeginDownload = DateTime.Now; // SECTION 1. Create a DOM Document and load the XML data into it. XmlDocument dom = new XmlDocument(); dom.Load(myStream); // SECTION 2. Initialize the TreeView control. treeView1.Nodes.Clear(); DateTime now = DateTime.Now; TimeSpan diff = now - BeginDownload; this.Text += (" 1=" + diff.TotalSeconds.ToString()); treeView1.Nodes.Add(new TreeNode(dom.DocumentElement.Name)); TreeNode tNode = new TreeNode(); tNode = treeView1.Nodes[0]; // SECTION 3. Populate the TreeView with the DOM nodes. AddNode(dom.DocumentElement, tNode); treeView1.ExpandAll(); now = DateTime.Now; diff = now - BeginDownload; this.Text += (" 2=" +diff.TotalSeconds.ToString()); } catch (XmlException xmlEx) { MessageBox.Show(xmlEx.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } } Show quote "Lloyd Dupont" <net.galador@ld> wrote in message news:OcZ3%23o7IHHA.420@TK2MSFTNGP06.phx.gbl... > As I don't have the code (nor the required MSDN version, it seems) I could > suggest 2 things (without knowing how relevant they are): > > 1. I will create all the node without attaching them to a TreeView. > When all the node would have been created I will add the top level ones to > the TreeView. > This way you minismize your calls to the TreeView class. Which is a > performance bottleneck as all WinForm control which are think wrapper > around win32 controls (such as the treeview) don't behave well. > > 2. I will go on www.codeproject.com and use one of their fully managed > TreeView class/sample. Which would probably behave much better the the one > in the framework.... > > "remo" <brig***@onlinepansystem.ch> wrote in message > news:%23cMB5r1IHHA.1276@TK2MSFTNGP04.phx.gbl... >> Hi >> Yes please let me know about... >> >> Thanks and regards remo >> >> "Lloyd Dupont" <net.galador@ld> wrote in message >> news:%23mtb0o1IHHA.1240@TK2MSFTNGP03.phx.gbl... >>>I don't have this article.... >>> Anyway IF you purpose is to improve the speed of this operation >>> I could suggest a couple of things. >>> >>> "remo" <brig***@onlinepansystem.ch> wrote in message >>> news:%23ZY9Hg0IHHA.1816@TK2MSFTNGP06.phx.gbl... >>>> Hello >>>> The code is copied from MSDN here is the link: >>>> >>>> Knowledge Base: >>>> How to populate a treeview control with XML data in Visual C# 2005 >>>> or in visual C# .NET >>>> >>>> >>>> ms-help://MS.VSCC.v80/MS.MSDN.vAug06.en/enu_kbnetframeworkkb/netframeworkkb/317597.htm >>>> >>>> Running on a Dell Inspiron 9400 dualcore, with 2GB Ram >>>> Intel CPU T2400 @1.83GHz >>>> >>>> Using VisualStudio 2005 and C# >>>> The XML File is 158kb and has the folowing structure: >>>> <Root> >>>> <sz> x="1.1" y=1.1</sz> >>>> <mx> x="1" y=1</mx> >>>> <dm> >>>> <dc x="1" y="1"/> >>>> <op x="1.1" y="1.1"/> >>>> <fp x="1.1" y="1.1"/> >>>> <fs x="1.1" y="1.1"/> >>>> <fr x="1.1"/> >>>> <dv> >>>> <bpc x="1"/> >>>> <op x="1.1" y="1.1"/> >>>> <fp x="1.1" y="1.1"/> >>>> <fs x="1.1" y="1.1"/> >>>> <fr x="1.1"/> >>>> <bp> >>>> <op x="1.1" y="1.1"/> >>>> <fp x="1.1" y="1.1"/> >>>> <fs x="1.1" y="1.1"/> >>>> <fr x="1.1"/> >>>> <Req x="1"> >>>> <st>1</st> >>>> </bp> >>>> </dv> >>>> </dm> >>>> </Root> >>>> This is only the structure, the names are 10..15char's long >>>> The attributes "1.0" are floats >>>> The "1" are integer values >>>> >>>> Each dm contains 64 dv's >>>> Each dv contains one bp >>>> There are 4 dm's and 64 dv's in one dm: 256 dv's and 256 bp's >>>> >>>> Loading the XML DOM using about 40ms ... 500ms >>>> Loading the tree using about 55..58s >>>> >>>> regards remo >>>> >>>> >>>> >>>> >>>> >>>> "Yves. L." <Yv***@discussions.microsoft.com> wrote in message >>>> news:u4%23DDIrIHHA.536@TK2MSFTNGP02.phx.gbl... >>>>> Send some sample code and somebody might find an answer. >>>>> >>>>> >>>>> remo wrote: >>>>>> Not my code is slow! >>>>>> MS code is slow! >>>>>> ... >>>>>> >>>>>> >>>>>> >>>>>> "Lloyd Dupont" <net.galador@ld> wrote in message >>>>>> news:OlHHDolIHHA.1248@TK2MSFTNGP03.phx.gbl... >>>>>>> Mhh... interesting. >>>>>>> Out of curiosity, why do you write slow code? >>>>>>> >>>>>>> "remo" <brig***@onlinepansystem.ch> wrote in message >>>>>>> news:OnlnS7UIHHA.4216@TK2MSFTNGP06.phx.gbl... >>>>>>>> Cant believe it: >>>>>>>> Loading an XML document (150kb) in a treeview using .net 2.0 using >>>>>>>> 2.0 seconds!!! >>>>>>>> That is unusable!!! >>>>>>>> Loading the same document in Iexplore, it needs 1/100 of a second >>>>>>>> That could not be .net >>>>>>>> That is incredible, and non usable. >>>>>>>> What in the hell do ms wasting the time... >>>>>>>> >>>>>>>> regards remo >>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>> >>> >>> >> >> > > |
|||||||||||||||||||||||