Print Page | Close Window

BindingManagers

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1789
Printed Date: 21-Apr-2026 at 10:39am


Topic: BindingManagers
Posted By: sky40627
Subject: BindingManagers
Date Posted: 06-May-2010 at 5:19am
I am working with Devexpress and use XtraGrid and the LayoutControlGroup
 
In both I want to add the properties of the entities programmatically.
 
I saw the example of the Gridbuilder which is excellent but does not add navigation properties .
 

XtraGridBindingManager bindingManager = new XtraGridBindingManager();

bindingManager.BoundType = gridSpecifier.EntityType;

bindingManager.GridView = gridSpecifier.DataGridView;

foreach (EntityProperty property in gridSpecifier.EntityProperties)

{

IdeaBlade.UI.ViewDescriptor pviewDescr =  new IdeaBlade.UI.ViewDescriptor(property.Name,

property.EntityType, property.Name);

XtraGridBindingDescriptor descriptor =

new XtraGridBindingDescriptor(pviewDescr);

bindingManager.Descriptors.Add(descriptor);

}

 
Example I have a grid of customers and I want to add the following
 
Customer.Name
Customer.Address.Street -> Address is another entity
Customer.Address.PostalCode
Customer.Address.Country.Name - > Country is yet a degree deeper
 
How can I add this programmatically I know it is possible at designtime.
 



Replies:
Posted By: sky40627
Date Posted: 06-May-2010 at 9:31am
If I could only find out how the XtraGridBindingManager is building up the properties treeview
 
I got to the point of getting the properties, but still not the related properties
 

Entity emp = _entityManager.GetNullEntity<T>();

foreach (var item in emp.EntityAspect.EntityMetadata.EntityProperties)

{

listOfProperties.Add(item);

}


Posted By: davidklitzke
Date Posted: 06-May-2010 at 9:47am
Is this a DevForce 2010 question or a DevForce 2009 question?  We support UI BindingManagers from DevExpress in DevForce 2009, but do not currently support these BindingManagers  in DevForce 2010.  You posted this in the DevForce 2010 section of the Forum.


Posted By: sky40627
Date Posted: 06-May-2010 at 10:05am
I guess when you do no longer support the BindingManagers there is another question.
 
How do we bind the XtraGrid in Devforce 2010 ? Is there another way ?
 
Bindingmanager helped me alot in the past, performance was better !!
 
When binding entities directly to the grid performance when scrolling in the grid was bad.
 
Since changing rows fired up several sql command fetching the children.
 


Posted By: ting
Date Posted: 06-May-2010 at 7:31pm
We will be releasing the BindingManagers for DevForce 2009 and DevForce 2010 in a few weeks.
 
I'm assuming that you know how to bind to nested property paths like this:
bindingManager.Descriptors.Add("Name", "Name");
bindingManager.Descriptors.Add("Street", "Address.Street");
bindingManager.Descriptors.Add("Zip Code", "Address.PostalCode");
bindingManager.Descriptors.Add("Country", "Address.Country.Name");
 
- and that you want to get the navigation properties at runtime from the EntityMetadata.
 
You can get the collection of navigation properties that return a single entity using this:
IList<NavigationEntityProperty> scalarProperties = employee.EntityAspect.EntityMetadata.ScalarNavigationProperties;
 
and scalarProperties[0].Name will be "Address" or whatever happens to be first in your model.
 
 
 
 


Posted By: sky40627
Date Posted: 06-May-2010 at 11:17pm
bindingManager.Descriptors.Add("Country", "Address.Country.Name");
 
that i know, but where can i find the "Address.Country.Name" in the (Data)(Navigation)properties ?
 
I am sorry but the ScalarNavigationProperties I did not find, but that could be the solution.
 


Posted By: ting
Date Posted: 07-May-2010 at 4:02pm
ScalarNavigationProperties is a property on the EntityMetadata.  I'm not sure why that wouldn't show up.
 
If you're saying you can't find the the full string "Address.Country.Name" on the ScalarNavigationProperties, that's because that path navigates multiple objects and you'll only find one piece of the name on each object.
 
In other words, you should find a ScalarNavigationProperty on Customer with Name "Address".
On Address you should find a ScalarNavigationProperty with Name "Country".
And on Country you should find an EntityProperty with Name "Name".
 
This assumes that Customer, Country, and Address are all mapped in the same EDMX and that Customer.Address and Address.Country each return a single object.
 


Posted By: sky40627
Date Posted: 26-May-2010 at 2:34am
Since Devforce is moving away from BindingManagers, I have been looking in the new 2010 samples
 
and I found this
 
//AddColumn(this._orderDetailsDGV, OrderDetail.PropertyMetadata.Product.ProductName); <--
AddColumn(this._orderDetailsDGV, OrderDetail.PropertyMetadata.OrderID);
AddColumn(this._orderDetailsDGV,  OrderDetail.PropertyMetadata.Product);
AddColumn(this._orderDetailsDGV, OrderDetail.PropertyMetadata.OrderID);
 
so I am changing my applications not to use bindingmanagers anymore.
 
But my question is, is there an elegant way to show for ex. my ProductName in the grid ?
 
I can not find this in any of the samples.
 


Posted By: ting
Date Posted: 26-May-2010 at 8:30pm

.NET WinForms does not have an easy way to bind to a nested property path (e.g. OrderDetail.Product.ProductName).  That was once of the much loved features of the BindingManagers.

Btw, the BindiingMangers aren't going away.  We have them in beta for DevForce 2010 and you can get it here:
http://ideablade.com/friends/DevForce2010WinFormsBeta.zip - http://ideablade.com/friends/DevForce2010WinFormsBeta.zip
 
Just be aware that the toolbox installer doesn't work, so you'll have to add all the components manually to the Visual Studio toolbox.
 


Posted By: sky40627
Date Posted: 26-May-2010 at 10:08pm
Will I be needing a Devforce Classic license ? (I have a Devforce Universal now)
 
Will they continue to be supported ?


Posted By: ting
Date Posted: 27-May-2010 at 5:35pm

The WinForms databinders are included in the DevForce Universal License.  You only need a DevForce Classic license if you want to develop using our pre-Entity Framework ORM.

We will continue to update the databinders to support updates to the DevExpress and Infragistics control suites.
 



Print Page | Close Window