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 

BindingContext ?

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
flc.net



Joined: 21 Jun 2005
Posts: 89
Location: Switzerland

PostPosted: Thu Jun 23, 2005 1:38 pm    Post subject: BindingContext ? Reply with quote

Hi

Is it possible to keep syncronized Virtual Tree with other Controls assigning the same BindingContext? --> Like DataGrid (ComplexBinding for Navigation) and a lot of Controls (SimpleBinding for displaying/editing all Details values).

Thanks and Best Regards
Giuseppe
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Jun 23, 2005 11:17 pm    Post subject: Reply with quote

Currently VirtualTree does not track the binding context CurrencyManager(s) CurrentChanged event nor does it set this. This is for performance reasons - because a tree may consist of thousands (or millions) of individual list data sources - each of which would require its own CurrencyManager to use this mechanism.

We are considering implementing this for the root list data source so that if you are using VirtualTree as a non-hierarchical listview you can make use of this functionality.

It is actually easy to implement this functionality yourself by simply handling the SelectionChanged event (or overriding the OnSelectionChanged) method and adding the following code.

Code:

private void _virtualTree_SelectionChanged(object sender, System.EventArgs e)
{
     object selectedItem = _virtualTree.SelectedItem;

    // assuming your data source is a simple list
    //
    IList dataSource = _virtualTree.DataSource as IList;
    CurrencyManager cm = (CurrencyManager)BindingContext[dataSource];
    if (selectedItem == null)
        cm.Position = -1;
    else
        cm.Position = dataSource.IndexOf(selectedItem);
}


In general however the binding context mechanism is not well suited to the hierarchical nature of the tree and you are probably better just handling the selection event directly and binding the forms controls directly to the newly selected object eg:

Code:

private void _virtualTree_SelectionChanged(object sender, System.EventArgs e)
{
     object selectedItem = _virtualTree.SelectedItem;

     if (selectedItem is Customer)
     {
          // _lastNameText and _firstNameText are textbox controls
          //
          this._lastNameText.DataBindings.Add(new Binding("Text", selectedItem, "LastName"));
          this._firstNameText.DataBindings.Add(new Binding("Text", selectedItem, "FirstName"));
    }
}

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






PostPosted: Fri Jun 24, 2005 6:27 am    Post subject: Reply with quote

thanks for the fast and detailed answer.
you have very a fantastic support!

best regards
giuseppe
Back to top
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