Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid question
Message
 
 
À
27/05/2003 09:54:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00792933
Message ID:
00793342
Vues:
31
>Hi Jim.
>
>That's really neat, Marcia, but I'm still scared by the idea of having BINDEVENT() coded all over the place in an application.
>
>Oh I have no doubt that there are all kinds of creative ways in which the developer can shoot himself (or herself < s > ) in the foot by using BINDEVENT() indiscriminately.
>
>I have found it useful in a couple of instances where I needed to change the behavior or controls that could not be accomplished very conveniently in any other way. For example, in the application that I am working on now, I added a method called SetDefaultValue() to my combo boxes so that a default value could be set when a new record is added to the cursor. The default code just sets the combo's list index to 1. But I did not want to go into all of my forms and call that method from the form's AfterAddNew() method for any of the combo boxes on that form. What I did instead was add 2 properties to my combo box:
>
>cHandlerName: default is Thisform
>cHandlerMethod: default is AfterAddNew
>
>add this code to the combo box's init():
>
>
>IF NOT EMPTY( This.cHandlerName ) AND NOT EMPTY( This.cHandlerMethod )
>  IF PEMSTATUS( EVALUATE( This.cHandlerName ), This.cHandlerMethod, 5 )
>    BINDEVENT( EVALUATE( This.cHandlerName ), This.cHandlerMethod, This, 'SetDefaultValue' )
>  ENDIF
>ENDIF
>
>
>I thought it was a pretty elegant solution to my problem < s >.

Neat. Another solution would be "turning SetAll into method execution". This idea was described in FoxTalk (or Foxpro Advisor) several years ago and then explained here by Trey Walpole. I used it then successfully in few applications and I think, it could be used here as well. Which proves again, about different ways to skin the cat... :)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform