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 

Programmatic Data Binding

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
salomo
Guest





PostPosted: Tue Apr 05, 2005 8:32 am    Post subject: Programmatic Data Binding Reply with quote

I'm looking for simple example for programmatic data binding which use the event handling method.
For a simple test I have added one column and overwritten the GetCellData event:


private void virtualTree1_GetCellData(object sender, GetCellDataEventArgs e)
{
e.CellData.Value = "test";
}

But this has no effect, because the event will not fired. Question

Thanks
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Apr 05, 2005 9:31 am    Post subject: Reply with quote

You have to do two other things. First set the datasource. The object you set as datasource acts as the root node for the tree. Second you must also handle the GetChildren event to (at least) provide the children for the root node.

Here is a minimal example:

Code:

// constructor
public Form1()
{
    InitializeComponent();

    ArrayList list = new ArrayList();
    for (int i=0; i < 10; i++)
    {
        list.Add(i);
    }
    virtualTree.DataSource = list;
}

private void virtualTree_GetChildren(object sender, GetChildrenEventArgs e)
{
    if (e.Row.Item is ArrayList)
    {
        e.Children = e.Row.Item as IList;
    }
}

private void virtualTree_GetCellData(object sender, GetCellDataEventArgs e)
{
    if (e.Column == mainColumn)
    {
        e.CellData.Value = e.Row.Item.ToString();
    }
}

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
salomo



Joined: 05 Apr 2005
Posts: 13
Location: Potsdam (Germany)

PostPosted: Tue Apr 05, 2005 11:14 am    Post subject: Reply with quote

Thanx, Really fast support Smile

That helps. I have adapted this example to bind my objects to the treelist.
But how can make changes in my object's when I use a celleditor in the VirtualTree. Which event from which control (treeList or Column or CellEditor) is responsible to update my object data.

Cheers & Thanx salomo
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Apr 05, 2005 10:26 pm    Post subject: Reply with quote

Have a look at the SetCellValue event
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Grant
Guest





PostPosted: Wed Oct 05, 2005 1:48 am    Post subject: How to use with no IList datasource? Reply with quote

Hi,

I would like to use the control as a virtual list view. My data does not support the IList interface. It contains a large number of records, so I can't copy the data to something that support IList. Extremely fast virtual rendering of the data is critical in my application.

The documentation indicates, in reference to Programmatic Data Binding, that:

"...It can also be used to handle binding to data that does not support the IList interface."

Are you able to provide an example or some guidence as to how this is done? I am probably missing something, but it appears you must supply a datasource, and the datasource appears to have to support IList.

Thanks in advance.

Grant Johnson
Advansys Pty Limited
Sydney, Australia
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Oct 05, 2005 8:38 am    Post subject: Re: How to use with no IList datasource? Reply with quote

Grant wrote:
Hi,
The documentation indicates, in reference to Programmatic Data Binding, that:

"...It can also be used to handle binding to data that does not support the IList interface."



We may have to change that documentation as it is a little misleading. That is not to say that you can't do this - just not directly. What sort of interface does your data source interface implement?

The simplest solution (if copying to another list is too expensive) is to create a simple wrapper class that implements IList and calls the necessary methods on your data source. You only have to provide meaningful implementations of the Count, Item, IndexOf and Contains methods. You then use programatic data binding and in the GetChildren event create an instance of your wrapper class (typically passing the data source to the wrapper in the constructor). This solution has the advantage that you can then use your data source in any standard .NET control. If your datasource supports some sort of notification scheme then you can get even more sophisticated by implementing IBindingList. We can give you more help if you need it with implementing IList.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
grantjohnson



Joined: 05 Oct 2005
Posts: 2

PostPosted: Thu Oct 06, 2005 1:46 am    Post subject: Reply with quote

Thank you for the fast response.

The data source is a 'hit' list supplied via the Lucene search engine. It is a virtual list of hits that are accessed via an index value. It does not implement IList (or any other of the collection interfaces). It pages the first 20 or so hits to improve performance, with subquent hits being pages as requested. Unfortunately, copying the entire result set to something that does support IList will be too expensive. I suspect I will have to go down the path of implementing a 'dummy' IList class that provides minimal implementations of the methods you mentioned.

So to confirm my understanding of the virtualisation model, the object assigned to the DataSource property _must_ implement IList in all situations, even when the programmatic data binding approach is being used?

Thanks again.

Grant Johnson
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Oct 06, 2005 2:01 am    Post subject: Reply with quote

grantjohnson wrote:

So to confirm my understanding of the virtualisation model, the object assigned to the DataSource property _must_ implement IList in all situations, even when the programmatic data binding approach is being used?


The object assigned to the DataSource does not have to implement IList - but the lists of child objects returned in the GetChildren event (or GetChildrenForRow method) do have to implement IList. This is because the tree needs two things:

1. The number of children (so it can accurately calculate the scrollbars)
2. The ability to retreive the child item at a given index - this allows you to scroll quickly over a very large list without having retreive every item in the list.

Do you know the total count of your data source upfront? Can you retreive data from the data source by index (ie give me the page containing the 20034th item)? If so you can easily implement an IList wrapper. If your datasource doesn't support this you still may be able to implement an IList wrapper - but it will be a bit more complicated.

Since you are also "down under" if you would like some to give you a call to talk about your options we would be happy to do that - just email your contact details to support@infralution.com
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
grantjohnson



Joined: 05 Oct 2005
Posts: 2

PostPosted: Mon Oct 24, 2005 12:44 am    Post subject: Reply with quote

Thanks for the additional information, and offer of a phone call. Sorry for the delay in my response - we had to get a beta out ASAP, so it was a case of drop everything. We are now back onto getting the release version available, which will most likely use the Virtual Tree control.

I suspect we probably has enough information to move forward at the moment. Another engineer here has taken ownership of this part of the project, so he may have some questions. We'll let you know how we get on.

Thanks

Grant
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support 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