Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I add a node to the Tree?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Infralution Support Forum Index -> Virtual Tree FAQ
View previous topic :: View next topic  
Author Message
Infralution



Joined: 28 Feb 2005
Posts: 4918

PostPosted: Mon Sep 12, 2005 1:52 am    Post subject: How do I add a node to the Tree? Reply with quote

Virtual Tree's programming model is a bit different to the standard .NET tree and list view. It is fully data bound - which means that you don't add visual display elements (such as rows or nodes) yourself. Instead you provide it with a data source (such as a list of objects) and it builds the visual display. If you've used data bound ListBox and ComboBox controls you'll know how much simpler this makes the programming task. Virtual Tree brings this same power and simplicity to Tree and List View controls.

So, to return to the original question, you don't create rows directly. Instead you create a list of objects that you want to display (for instance you can create an ArrayList of FileInfo objects) and set this as the data source for your tree. Then you use the Virtual Tree designer (right click on the control) to create RowBindings for the objects you are displaying. The RowBindings tell Virtual Tree how to map the properties of a given object type to the user interface display elements. If you use the Auto Generate function it will automatically create columns for each for the public properties of the given object type and RowBindings that map the object properties to columns.

To add a new row you simply add an object to the collection that you set as the data source. If your data source collection supports two way data binding (via the IBindingList interface) then Virtual Tree will automatically update to display the change. If it is a simple collection, such as an ArrayList, then you can call VirtualTree.UpdateRows to refresh the display after making changes to the collection.

Why do we use this approach? In a typical application using a standard TreeView you have to write a large amount of code handling the relationship between your data model and the display. Virtual Tree's data binding model handles this for you automatically and seemlessly - allowing you to concentrate on the core functionality of your application.

The other main advantage of the fully data bound approach is that it enables Virtual Tree to be very quick and resource efficient - because it creates the display elements it needs to display the current data on the fly. Other tree controls that support some form of databinding just build it on top of their standard unbound mode. This means that they parse the data source and create all the user interface elements (nodes etc) upfront when the data source is set. For a very large data source this can take a long time and consume a great deal of memory. You can only leverage the true power and performance of data binding by abandoning the traditional unbound model altogether.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Infralution Support Forum Index -> Virtual Tree FAQ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group