Binding a Control (Button) to a Function with a BindingSource RRS feed

  • Question

  • Is it possible to bind a control (specifically a button) to a function. 


    What I am trying to do is make my TextBox controls sensitive to the state of my BindingSource.  For example if my BindingSource raises an AddNew event my extended textboxes would be enabled allowing the user to type data into them or if my BindingSource raises a BindingComplete Event the textboxes are disabled so they cannot change the data in them.  I can extend the TextBox class to handle these and other events. This gives me a unformity for all of my text controls and keeps me from having to mainting a lisit of TextBox1.Enabled (and other things) in my On_Click button events. 


    What I need is a way for my Buttons to be tied to my BindingSource so as to be "bound" to a certain function.  A New button would trigger either the builtin AddNew or a custom NewRecord function.  As Save button would trigger a Function that called EndEdit and then passes the updated Datatable to the Webservice. 


    I don't want to hard code the BindingSource into my button class because I want these custom buttons to be usable with any BindingSource (or at least any of my extended BindingSources). 


    I've come up with some ideas and all of them are ugly.  Any thoughts?

    Wednesday, July 4, 2007 1:07 PM