Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Toolbar & Textbox
Message
 
À
03/04/2000 14:29:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00354468
Message ID:
00354491
Vues:
17
>I have a form with one textbox and i have a toolbar.
>A command button in the toolbar efects a method from the active form.
>The methods code is :
>
>tableupdate(.t.)
>thisform.release
>
>My problem is when i click the command button, the field from the textbox updates blank.
>
>Thanks.

Cemal, the problem here is that when you click on the toolbar button your textbox is not loosing the focus, so it does not validate the entered value.
In general you need the to call custom Form.Writebuffer() method from your button before TABLEUPDATE(), which will take care of that.
Here is tsBaseForm.Writebuffer() from Tasmanian Traders VFP sample.
***********tsBaseForm.Writebuffer()
LOCAL llRetval
llRetVal = .T.

*-- Code to save field value to buffer when
*-- clicking on toolbar without leaving the field
*-- Don't do this for a grid since a grid may change
*-- work areas unexpectedly
IF TYPE("thisform.ActiveControl") == "O" AND ;
    UPPER(thisform.ActiveControl.BaseClass) <> "GRID"
  IF TYPE("thisform.ActiveControl.ControlSource") <> "U" AND ;
      !EMPTY(thisform.ActiveControl.ControlSource)
    IF EVAL(thisform.ActiveControl.ControlSource) <> thisform.ActiveControl.Value
      REPLACE (thisform.ActiveControl.ControlSource) WITH thisform.ActiveControl.Value
      *-- We rely on the fact that we revert the field's value
      *-- in the error event method for the form. 
      llRetVal = (EVAL(thisform.ActiveControl.ControlSource) = thisform.ActiveControl.Value)
    ENDIF
  ENDIF
ENDIF

RETURN llRetVal
All commercial frameworks have similar kinds of Form.WriteBuffer() method in their base form classes.

HTH
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform