DimkaNewtown Posted December 7, 2005 Posted December 7, 2005 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? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.