Custom classes and linq + databinding
-
Im makeing a customer textbox for handling updates to db. I have never got the regular databinding to update my db when the "lost focus" event runs. So ive made up my mind to create a custom class for it.
class CustomerTextBox : TextBox { protected override void OnLeave(EventArgs e) { Binding TextProperty = this.DataBindings["Text"]; Binding TagProperty = this.DataBindings["Tag"]; } }
When focus is lost then this method runs. Now, how can i add support for all possible bindings so that i dont need to make a customer textbox class for handeling Customer updates, anohter for handling Reservation updates and so on. I can get the fields of the binding itself by looking at the TextProperty.BindingMemberInfo property. But how do i for example handle the fact that this fields sometimes are bound to Reservations table, and another textbox is bound to the Customers table. I need to extract the type of the table, create a new instance of that object. Retrive the disierd row from the db and then update the field found in the TextProperty.BindingMemberInfo property. And this must work for all possible tables and field in the db. Any ideas? :) Tnx