Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listbox column format
Message
De
06/07/2004 20:30:40
Ken Dibble
Southern Tier Independence Center
Binghamton, New York, États-Unis
 
 
À
06/07/2004 08:38:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00920976
Message ID:
00921255
Vues:
15
>Dear Sir,
>
>I want to get your help
>
>I have a listbox that contains six columns
>The leftmost three columns are character fields and others three are numeric
>type.
>
>I want to show numeric fields, in listbox, as following format
>
>99,99,999.99
>
>Which rowsource and rowsource type should I use?
>
>Please help with some examples.
>
>Thanking you in advance

Hi Tariq,

Try this:
CREATE CURSOR curTest ( ;
     Char1 c(10), ;
     Char2 C(10), ;
     Char3 C(10), ;
     Num1 N(12,2), ;
     Num2 N(12,2), ;
     Num3 N(12,2))
   
FOR x = 1 TO 10
     y = TRANSFORM(x)
     thec1 = "Char1f" + y
     thec2 = "Char2f" + y
     thec3 = "Char3f" + y
     then1 = x * 1000000.99
     then2 = x * 1000000.99
     then3 = x * 1000000.99
     
     INSERT INTO curTest (Char1, Char2, Char3, Num1, Num2, Num3) ;
     VALUES (thec1, thec2, thec3, then1, then2, then3)
ENDFOR

oForm = CREATEOBJECT("Form")

WITH oForm
     .Width = 450
     .AddObject("List1","Translist")
     .List1.Top = 10
     .List1.Left = 5
     .List1.Height = 200
     .List1.Width = 440
     .List1.Visible = .T.
     .AddObject("cmd1","FillButton")
     .cmd1.Top = 220
     .cmd1.Left = 140
     .cmd1.Visible = .T.
     .AddObject("cmd2","TransButton")
     .cmd2.Top = 220
     .cmd2.Left = 240
     .cmd2.Visible = .T.
     .Show(1)
ENDWITH

DEFINE CLASS TransList AS ListBox
     ColumnCount = 6
     ColumnWidths = "54,54,54,80,80,80"
     
     PROCEDURE Init
          WITH THIS 
               .AddProperty("aTheSource[1]","")
               .RowSourceType = 5
               .RowSource = "THIS.aTheSource"
          ENDWITH
     ENDPROC
     
     PROCEDURE FillListBox
          DIMENSION THIS.aTheSource(1,6)
          THIS.aTheSource = ""
          
          SELECT * FROM curTest INTO ARRAY THIS.aTheSource
          
          THIS.Requery()
          
          THIS.Parent.cmd2.Enabled = .T.
     ENDPROC
     
     PROCEDURE TransformList
          FOR x = 1 TO ALEN(THIS.aTheSource,1)
               THIS.aTheSource(x,4) = TRANSFORM(THIS.aTheSource(x,4),"###,##,###.##")
               THIS.aTheSource(x,5) = TRANSFORM(THIS.aTheSource(x,5),"###,##,###.##")
               THIS.aTheSource(x,6) = TRANSFORM(THIS.aTheSource(x,6),"###,##,###.##")
          ENDFOR
          
          THIS.Requery()
          
          THIS.Parent.cmd2.Enabled = .F.
     ENDPROC
     
ENDDEFINE     

DEFINE CLASS FillButton AS CommandButton
     Caption = "Fill"
     Height = 22
     Width = 70
     
     PROCEDURE Click
          THIS.Parent.List1.FillListBox()
     ENDPROC
ENDDEFINE

DEFINE CLASS TransButton AS CommandButton
     Caption = "Transform"
     Height = 22
     Width = 70
     Enabled = .F.
     
     PROCEDURE Click
          THIS.Parent.List1.TransformList()
     ENDPROC
ENDDEFINE
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform