View previous topic :: View next topic |
Author |
Message |
scottietrek
Joined: 28 Aug 2008 Posts: 5
|
Posted: Thu Aug 28, 2008 8:29 pm Post subject: Help with e fairly simple VirtualTree |
|
|
Ok all i want to do is use an xml file to bind to the VirtualTree. I can add items without issue but i cannot figure out how to make them editable I am using VS 2008 pro if that helps with the latest version Virtualtree
i only rows with childrows basicly multiable rows with multiable children only going down once. I am just not able to make VirtualTree bind to any database. Much less a XML file. Any help pointing me in the right direction would be great.
Thanks in advance. _________________ lost |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Aug 28, 2008 10:45 pm Post subject: |
|
|
So you can display the items OK but you can't edit them?
You need to add an Editor using the Virtual Tree designer. If you are only editing text then use the standard TextBox control as the editor control. Then you need to set the Editor property for the column(s) you want to be able to edit. _________________ Infralution Support |
|
Back to top |
|
|
scottietrek
Joined: 28 Aug 2008 Posts: 5
|
Posted: Thu Aug 28, 2008 11:27 pm Post subject: yes but |
|
|
i can add them but not from an xml file. just using the part file sample. i have tried the text box control in the editor and it does show up but when i change the vale it does not change it in the list. _________________ lost |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Aug 28, 2008 11:59 pm Post subject: |
|
|
Quote: | i have tried the text box control in the editor and it does show up but when i change the vale it does not change it in the list. |
That's because the cell is bound to the Name property of the Part class in this sample project - and there is no Set accessor defined for the Name property. If you define a Set accessor than the value should change when you change it with the editor.
Quote: | i can add them but not from an xml file. |
The solution here depends on exactly what you are trying to achieve. If you have a known XML structure then the best solution is to create a set of classes/objects that reflect this structure and read the XML into your objects using the standard .NET XML serialization or read/write methods. Then you can bind to your objects in exactly the same way that the Simple Parts sample does.
If you are trying to build a general purpose XML file browser (like what you get if you open an XML file using Windows Explorer) then this a slightly bigger task. It is possible to bind a Virtual Tree to an XmlDocument - however it takes a little bit of work because the XmlNode collections don't support the standard .NET IList interface. If you want to do this let us know and I can provide some more information on how to go about it. _________________ Infralution Support |
|
Back to top |
|
|
scottietrek
Joined: 28 Aug 2008 Posts: 5
|
Posted: Fri Aug 29, 2008 2:49 pm Post subject: need to do |
|
|
What i am trying do to is use an XML doc that i can format anyway needed as i will be creating it.
the needs:
i have 2 columns
Name and status
The user should be able to change the name only.
there will be one child set for every project ie...
Code: |
Name status
Untitled Project active
Untitled SubProject Inactive
Untitled SubProject1 Inactive
Untitled SubProject3 Inactive
Untitled Project1 active
Untitled SubProject1 Inactive
Untitled SubProject11 Inactive
Untitled SubProject13 Inactive
|
not sure if this makes since
both subproject and project would need to be editable
i would like to bind this information to an xml document so that it update the xml document as they add projects and sub projects.
is there a way to do this also this is my firstime using Virtual tree.
which way would be bets for this.
and what would i do to accomplish the end result. _________________ lost |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Aug 29, 2008 11:29 pm Post subject: |
|
|
The best way to handle this to create a set of classes that reflect your model. So you might create a "Project" class. The Project has a "SubProjects" property that returns the collection of sub-projects (also Project objects) and a Parent property (null for root projects). A sub-project would then just be a Project which doesn't have a parent. The Projects class would have name and status properties. This is really similar to the simple sample using the "Part" class
Your application can then deal with the Project class instead of dealing directly with XML. There are a number of ways you can use .NET to write/read the class to XML. The easiest to implement is using the builtin XML serialization - I would look this up in Microsofts online help and some other sources (like CodeProject) if you haven't used it before.
Binding your data to Virtual Tree is then very easy using the object binding mechanism. It is essentially the same as the simple sample you have already been looking at. _________________ Infralution Support |
|
Back to top |
|
|
scottietrek
Joined: 28 Aug 2008 Posts: 5
|
Posted: Fri Aug 29, 2008 11:34 pm Post subject: thank you |
|
|
I did finally figure it out i beliive. doing pretty much what you have stated i just use an arraylist to house the children of the projects and a single string to house the projects as you edit or enable and disable the projects status it changes this informaition. I then have an xml writer and reader to retrieve this information as needed. at start up and close. works pretty well now. thank you so much for your help. _________________ lost |
|
Back to top |
|
|
|