Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do i color code text boxes based on db?
Message
De
11/01/2002 05:12:56
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00594778
Message ID:
00603386
Vues:
29
>Hi Guys,
>
>This is still not working for me. In the forecolor property of my text boxes i have "=f_color(this.value)".
>
>and in the f_color function, i am doing something simple like
>
>Do Case
>Case 1
> RETURN RGB(50,50,50)
>Case 2
> RETURN RGB(100,100,100)
>otherwise
> RETURN RGB(200,200,200)
>endcase
>
>When I run there are no errors but the font color is always black. What am I doing wrong?
>
>Thanks,
>
>Nancy

Nancy,
With the above code you should get a syntax error. Since you didn't I assume you made typo while writing here. Try this sample and you could accomodate it to yours :
oForm=createobject('myForm')
oForm.Show
Read events

Define class myForm as form
  Add object txt1 as myTextbox with left = 10, top= 10, name= 'txt1', ;
    value = 0, forecolor=rgb(192,192,192)
  Add object txt2 as myTextbox with left = 10, top= 30, name= 'txt2', ;
    value='text',forecolor=rgb(92,255,255)
  Add object txt3 as myTextbox with left = 10, top= 50, name= 'txt3', ;
    value = datetime()
  Add object txt4 as myTextbox with left = 10, top= 70, name= 'txt4', ;
    controlsource='myTest.f1'
  Add object txt5 as myTextbox with left = 10, top= 90, name= 'txt5', ;
    controlsource='myTest.f2'
  Add object txt6 as myTextbox with left = 10, top=110, name= 'txt6', ;
    controlsource='myTest.f3'
  Add object comb as commandbutton with left=200, autosize=.t., ;
    caption = 'txt2 to num, txt1 to char'
  Add object comb2 as commandbutton with left=200, top= 50, autosize=.t., ;
    caption = 'txt1 to num, txt2 to char'

  Procedure load
  Create cursor mytest (f1 i, f2 c(10), f3 d)
  Insert into mytest values (1,'hello',date())
Endproc

  Procedure queryunload
  Clear events
Endproc

  Procedure comb.click
  With thisform
    .txt1.value = 'hello'
    .txt1.setcolor()
    .txt2.value = 2
    .txt2.setcolor()
  Endwith
Endproc
  Procedure comb2.click
  With thisform
    .txt1.value = 1
    .txt1.setcolor()
    .txt2.value = 'hello'
    .txt2.setcolor()
  Endwith
Endproc
Enddefine

Define class  myTextbox as textbox
  Procedure Init
  This.setcolor()
Endproc
  Procedure lostfocus
  This.setcolor()
Endproc
  Procedure setcolor
  With this
    If type('.value')='N'
      Do case
      Case .value = 1
        lnColor = rgb(255,0,0)
      Case .value = 2
        lnColor = rgb(0,255,0)
      Case .value = 3
        lnColor = rgb(0,0,255)
      Otherwise
        lnColor = rgb(255,0,255)
      Endcase
      .Forecolor = lnColor
    Else
      .ResetToDefault('Forecolor')
    Endif
  Endwith
Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform