Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Use Optiongroup with logical data?
Message
De
20/01/2007 09:38:38
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01187180
Message ID:
01187333
Vues:
27
This message has been marked as the solution to the initial question of the thread.
A client wants an Optiongroup with Yes and No as choices for a logical field (bit datatype in SQL.) It seemed a reasonable request but now I'm not so sure that it's even possible. If so, what's the trick?

How about this class?
**************************************************
*-- Class:        opgLogical
*-- BaseClass:    optiongroup
*-- Option group that can be bound to a logical field - set the control's cControlSource property and NOT the ControlSource
*
Define Class opgcharacter As optiongroup

  ButtonCount = 2
  Name = "opglogical"
  Option1.Caption = "Yes"
  Option1.Height = 17
  Option1.Left = 5
  Option1.Top = 5
  Option1.Width = 61
  Option1.Name = "optYes"
  Option2.Caption = "No"
  Option2.Height = 17
  Option2.Left = 5
  Option2.Top = 24
  Option2.Width = 61
  Option2.Name = "optNo"
  BackStyle = 0
  Value = 0
  Height = 46
  Width = 71
  *-- To be used instead of controlSource for binding this control
  ccontrolsource = ""

  *-- Called from valid to update real controlsource
  Procedure updatecontrolsource
    Local lcField, lcAlias, lcControlsource, llValue
    *** From the value which is numeric
    If Not Empty( This.ccontrolsource )
      llValue = IIF( This.Value = 1, .T., .F. )
      lcControlsource = This.ccontrolsource
      If Upper( Left( lcControlsource, 4 ) ) == 'THIS'
        &lcControlsource = llValue
      Else
        lcField = Justext( lcControlsource )
        lcAlias = Juststem( lcControlsource )
        Replace ( lcField ) With llValue In ( lcAlias )
      Endif
    Endif
  Endproc


  *-- Called from refresh to update the real value
  Procedure updatevalue
    *** Read the value of the controlsource and use it to set the correct value for the control
    Local llValue, lnValue

    If Not Empty( This.ccontrolsource )
      llValue = Evaluate( This.ccontrolsource )
      lnValue = IIF( llValue, 1, 2 )
      This.Value = lnValue
    Endif
  Endproc

  Procedure Valid
    This.updatecontrolsource
  Endproc


  Procedure Refresh
    This.updatevalue()
    DoDefault()
  Endproc

Enddefine
**************************************************
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform