>>What would be the.net equivalent of the vfp textbox.programmaticchange event. Specifically I would like to apply a format on the .text at "loading" time, i.e. when bindingsource changes the underlying value of a bound control (textbox).
>
>Assuming this is WinForms (rather than ASP.NET or WPF) then look at the Binding.Format event:http://msdn.microsoft.com/en-us/library/system.windows.forms.binding.format.aspx
Thanks viv. Can this be used in a base class as well? I guess the New() method is executed before the binding is created by the form, then what would be the right event to add the handlers?
Update: I guess the form should go through all it's controls and execute the method that adds the handlers.
Update2: it works.
Thank you sooooo very much Viv;
Update3 : the binding.format works, but the binding.parse event does not seem to fire. I was hoping that when bindingsource would .endedit, the parse event would trigger, but it does not, in fact, curiously enough I get the feeling that the format event is triggered instead and the original value of the field is saved.
Here's the code for what that's worth:
Sub BindingFormat() Implements IControlBindingFormat.BindingFormat
Dim B As Binding = Me.DataBindings.Item(0)
AddHandler B.Format, AddressOf BooleanToJaNeen
AddHandler B.Parse, AddressOf JaneenToBoolean
End Sub
Sub BooleanToJaNeen(ByVal sender As Object, ByVal cEvent As ConvertEventArgs)
If cEvent.Value Is System.DBNull.Value Then
cEvent.Value = ""
Exit Sub
End If
cEvent.Value = IIf(cEvent.Value, "Ja", "Neen")
End Sub
Sub JaneenToBoolean(ByVal sender As Object, ByVal cEvent As ConvertEventArgs)
cEvent.Value = IIf(cEvent.Value = "Ja", True, False)
End Sub
If things have the tendency to go your way, do not worry. It won't last. Jules Renard.