Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Vfp .net event equivalent
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
OS:
Vista
Network:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01489449
Message ID:
01489979
Vues:
49
>>>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
>
I see Bonny has pointed out one possible cause but I get the impression it's a more general problem (i.e. not related to the control not losing focus) ?
IAC I don't see anything wrong in the code above (assuming that any entry other than "JA" translating to false is the expected behaviour). Bear in mind that it would be normal behaviour for the Format event to fire after the Parse (the data is round-tripped). The fact that it is firing at all seems to indicate something is happening.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform