Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Vfp .net event equivalent
Message
 
À
20/11/2010 19:16:59
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:
01489943
Vues:
44
In a "if you can't beat it, join it" spirit, I updated the bindingsource just before the (ta).update at the form level.

I must have misunderstood what that parse event was. I thought that if format fires when the underlying data gets communicated to the control, that parse would do the reverse....

Anyway, looking forward to your posting :).


>>... 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.
>
>More likely what is happening is that you're clicking on a MenuItem or ToolBar button ...these controls do not cause the ActiveControl to lose focus, thus not forcing the control's value into it's databound object, which is when the Parse event fires. You need something that will force this for every control you have (it's the Validated event that accomplishes this). It can get complicated.
>
>I have a method that I have named ForceBind() in most of my controls (those that have it implement an Interface I have created for this type of behavior). If the control is a container object that implements that Interface (such as a Panel, UserControl, etc.) it will call the ForceBind() method of *it's* ActiveControl (if *that* control implements the Interface).
>
>Hmmm ... maybe I should put all this, along with some code, in a blog post. I need to post something to my blog this month, so maybe this will be it. I'm not sure if this is your problem, Marc, but it certainly could be. Let me write something up for my blog and I'll post the link here once it's done.
>
>~~Bonnie
>
>
>
>>>>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform