Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reposition labels on forms
Message
De
04/02/2006 05:06:53
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/02/2006 19:49:42
Hong Yew
People Quest
Malaisie
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01093594
Message ID:
01093648
Vues:
21
>Hi all
>
>I need to call a form with some parameters and based on the parameters, change labels caption as well as hide some labels. After changing some label caption , I need to reposition the labels by computing the new left position of label.
>
>My code in the form INIT method is as below :
>
>Thisform.PGF.Page1.lbl_xyz.Left = Thisform.PGF.Page1.txt_beside.Left - Thisform.PGF.Page1.lbl_xyz.width -3
>
>The above code will not work bcos the label width is inaccurate in the INIT method. If I create a command button and put the above code in the Click method, it will work.
>I've tried putting the code in the Form Activate and Show methods as well as the Page Activate method, but could not get it to work. I would appreciate if you could point me to the right form Method that I should put the above code.
>
>Thanks in advance
>
>Best Regards

Init is the right place. Set label's autosize to .t. and .visible = .visible. ie:
(Assume there is a pageframe named pgf with label controls on it with different fontName and sizes, bold,italic etc):
this.SetAll('AutoSize',.t.) && Label autosize must be true for this to work
With This.pgf
 For Each oPage In .Pages
  For Each oControl In oPage.Controls
   With oControl
    If Lower(.BaseClass) = 'label'
     .Caption = Sys(1272,oControl)+'/' && set new caption
     .Visible = .Visible

     * add a texbox to the right of label - just to show width is updated
     lcNewName = 'txt' + .Name
     .Parent.AddObject(m.lcNewName, 'textbox')
     With Evaluate('.Parent.'+m.lcNewName)
      .Left = oControl.Left + oControl.Width
      .Top = oControl.Top
      .Visible = .T.
     Endwith
     * add a texbox to the right of label

    Endif
   Endwith
  Endfor
 Endfor
Endwith
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