I've seen quite a few posts here where people have no problems binding Infragistics controls to their NetTiers layer. I've been able to do this programmatically in the code, but then I lose the design-time capabilities of the UltraGrid designer in a WinForms based application.
Take for example my normal method of binding the UltraGrid to the old school ADO.net DataSet.
- First, I would drag out a TableAdapter, BindingSource, and my shared custom DataSet.
- Next, I would bind the binding source to the DataSet along with the DataMember that corresponds to the data I want.
- Then, I would drag out an UltraGrid and tell it to bind to the datasource.
By doing this, the UltraGrid would automatically create the columns at design-time, allowing me to further modify them at design-time. By doing it this way, I didn't have to actually write any code to modify the UltraGrid to get the initial appearance I wanted... it was done at design-time.
Now, with NetTiers, it seems the part of the above process that is missing is the DataSet component. It seems the only way to do something like this using similar steps as above is if I could drop the TList<whatever> onto the form as a component the same way I do with DataSet. However, I have no way of dragging a generic TList<whatever> object out onto the form canvas unless I create my own component that inherits from it.
As an experiment, I did the following and it seems to work with the exact functionality I'm looking for. I am just wondering if this functionality is already in NetTiers and I'm just missing it, or if I am going to have to build my own template generator within the NetTiers templates to create a template like this for every Entity that gets created if I want this kind of drag/drop functionality?
public class CustomerFormComponent : TList<Customer>, IComponent
{
private ISite _site;
public CustomerFormComponent(IContainer container)
{
_site = null;
container.Add(this);
}
#region
IComponent Members
event EventHandler IComponent.Disposed
{
add { Disposed += value; }
remove { Disposed -= value; }
}
ISite IComponent.Site
{
get { return _site; }
set { _site = value; }
}
#endregion
#region
IDisposable Members
void IDisposable.Dispose()
{
base.Dispose(true);
}
#endregion
}
Then, when I drag the component onto the form, it creates this for me in the designer partial code.
this.customerFormComponent1 = new CustomerFormComponent(this.components);
this.customerFormComponent1.AllowEdit = true;
this.customerFormComponent1.AllowNew = true;
this.customerFormComponent1.AllowRemove = true;
this.customerFormComponent1.ContainsListCollection = false;
this.customerFormComponent1.Filter = null;
this.customerFormComponent1.RaiseListChangedEvents = true;
this.customerFormComponent1.Site = null;
And to use it, all I have to do is something like this on form load.
customerFormComponent1.AddRange(
DataRepository.CustomerProvider.GetAll());
Since the binding source is already bound to the customerFormComponent1 at design-time, and the grid is already bound to the binding source, then this one line of code is all that's needed to fill up that beautiful Infragistics UltraGrid. Anything already in NetTiers that does this?