Binding object

DimkaNewtown

Freshman
Joined
Jan 21, 2003
Messages
43
Location
New York City
I understand the databinding concepts, however I have an issue.

When binding controls on a usercontrol to a custom object I am left to use late binding.
[csharp]
txtAccount.DataBindings.Add(new Binding("Text", _customer, "Account"));
[/csharp]

This completely defeats the purpose of design-time validation of properties which would occure if I do this
[csharp]
txtAccount.Text = _customer.Account;
[/csharp]

I could of course use reflection to get a list of properties from the object and a list of textbox/property-name pairs, iterate through it and bind them all dynamically. However this approach seems to be utilizing more resources than needed (by going through reflection object model) and does not fit into the application architecture well.

Wouldn't it be nice to be able write a simple line like so
[csharp]
txtAccount.DataBindings.Add(new Binding("Text", _customer, _customer.Account.PropertyName));
[/csharp]
or even
[csharp]
txtAccount.DataBindings.Add(new Binding("Text", _customer, nameof(_customer.Account)));
[/csharp]

Anyone?
 
Back
Top