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 

virtual dropdown list as editor

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



Joined: 31 Aug 2007
Posts: 7

PostPosted: Thu Sep 20, 2007 8:37 pm    Post subject: virtual dropdown list as editor Reply with quote

Hi all,

I use virtual tree to display Parent Child data on the screen. However, the child object has a property that references another object. Example
Parent obejct - Group
Child object - Attribute
Child object property - Attribute.Unit
The Unit object has ID and Description.
I need to display data in the following format:
Group1
Attribute1 Unit1
Attribute2 Unit2
Attribute3 Unit3
** Unit1 is a value of the Unit.Description property
I also would like to use virtual dropdown list as an editor populating it with the distinct list of Units.

Please help!!!

TIA
Milena
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Sep 21, 2007 12:10 am    Post subject: Reply with quote

Create a new Editor (using the Virtual Tree designer) and set the editor control to be a VirtualDropDownList. Set the Column.Editor property to this Editor. In your code, following the InitializeComponent, set the DataSource of the editor control eg

Code:
testDropDownList.DataSource = unitList;


Where unitList is a list of the possible Unit objects. Override the ToString method of the Unit class to return the Description of the Unit. Then (if you are using ObjectBinding) you can simply bind the Attribute.Unit property to the column.

The only other issue to resolve is that the .NET databinding design includes a mechanism to keep the selected items of databound controls (bound to the same datasource) on a form in sync via the BindingContext/CurrencyManager. To avoid all of the drop down controls changing selection in sync you need to disconnect them and give each control its own BindingContext. You do this by handling the CellEditor.IntializeControl event as follows:

Code:
private void cellEditor2_InitializeControl(object sender, CellEditorInitializeEventArgs e)
{
    if (e.NewControl)
    {
        e.Control.BindingContext = new BindingContext();
    }
}


We will be changing VirtualTree in the next release so that it gives each control its own binding context by default (so you won't have to do this)
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
kinetico



Joined: 31 Aug 2007
Posts: 7

PostPosted: Fri Sep 21, 2007 1:37 pm    Post subject: Reply with quote

Thank you very much for your great advice. I did everything you said and it resolved some of the issues.
Here is what can't work out. The unit column is bound to Attribute.Unit property. However, when I load the form none of the data is displayed in the Unit column.
Do I need to handle it in GetCellData event handler by setting e.celldata.value = attribute.unit.tostring
Is there any other way?

Thank very much for your help

Milena Voronkin
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Sep 21, 2007 10:03 pm    Post subject: Reply with quote

If you have implemented Unit.ToString() to display the description then simply binding to the Attribute.Unit property should display the description.

You could add a GetCellData handler - to see if there is an issue with your object binding, but you should set e.celldata.value = attribute.unit. Otherwise you won't be able to select the Unit using your drop down list (because the bound object will be a string not a Unit object).

If you could put together a sample project that illustrates your problem and email a zipped copy to support@infralution.com we could probably sort the issue out for you.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Sep 24, 2007 2:06 am    Post subject: Reply with quote

We have now released Version 3.5.6 of Virtual Tree. This version creates a separate binding context for each editor control by default. This eliminates the need to do this programmatically when using bound list controls as editors.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
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