Solved

Format Strings

Posted on 2006-07-20
8
518 Views
Last Modified: 2010-05-18
Hi

I Have a panel with 10 labels on it e.g...

Label1
Label2
Label3
eg......

On each label I display client Information like

Name : Jan Smith
Address : 1999 Bes str
Age : 30

I want to align each caption of the lables, currently  it looks like above HOW do i format a string to say to align up perfectly.
This is what iam doing currently.
navItemAccNo.Caption      := Format('%-20s',['Acc No'])+Format('%-1s',[':'])+trim(FieldByName('lPurCode').AsString);

BUT still I cant DO a perfect allignment like THIS...

Name     : Jan Smith
Address  : 1999 Bes str
Age        : 30

Thank you
0
Comment
Question by:henryreynolds
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 26

Expert Comment

by:Russell Libby
ID: 17145968

It really depends on the font that you are using. What you are trying to do above requires a fixed pitch font, or alternatively, split the name / value pairs into 2 sets of labels (in the above you would have 6 labels).

Regards,
Russell
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17145973
Only way to do this is to use a proportional font, like Courier New,  in the labels.

Otherwise, you can use two labels with the one on the left containing
'Name   :', 'Address  :' and 'Age    :' and make those right-justified and aligned to each other on the right
and then the ones on the right containing the data left-justified and aligned to each other on the left.


0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17145979
I meant fixed font, like rlibbly said, not proportional, which is what "MS Sans Serif" is.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:JeePeeTee
ID: 17146173
Dont try it the way you descibed. Split your labels from:

Label1
Label2
Label3
eg......

into

Label1a   Label1b
Label2b   Label2b
Label3c   Label3b
eg......

where Label1a = Data prompt and Label1b = Data value etc....
0
 

Author Comment

by:henryreynolds
ID: 17147290
Hi
The problem why I cant use two labels for each set is as follows:

I am using a TdxNavBar component from Developers express, and I want to give my user the same look as win xp, when you go into my computer and you see the task, and folder information on the left. I want the user to see on the left of the screen all the employee details in the navbar and on the rest of my form their are edit boxes to enter values.. That way on my navbar I want to Allign The Details as :

Name      : Jan
Surname : Koos

I MUST USER THE WORDING NAME, SURNAME,AGE,PASSPORT NUMBER, because otherwise the operator wont know what info are displaying.

Is their any other way how to align my detail, or must I use something else.

Thanx
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17147677
Without a fixed font, you will not be able to do it with one label, PERIOD.
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 200 total points
ID: 17148329

I have used the Nav Bar component as well, and this is how I handled issues such as this.

Instead of placing the labels on your panel, you place 2 panels on your panel.

- the left hand side panel is set to align left
- the right hand side panel is set to align client.

This will allow you to use 2 set of labels for each group. On the left hand side group, you would set the label's wordwrap to true, then add the text as:

'Name'+#13#10+'Address'+#13#10+'Age';

which will give you three lines of text. Then on the right hand side label, you would also set wordwrap on and add the text as:

': Jan Smith'+#13#10+': 1999 Bes str'+#13#10+': 30';

This will give you three lines of text on the right hand side. As well, if you want more border (filler) space between the name / value pair, you just increase the width of the left hand side panel.

Regards,
Russell


0
 

Author Comment

by:henryreynolds
ID: 17151735
Hi Russell

Thank you , this is perfect IT works 100%,

Henry
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Working with hours 3 88
drawing animated level bar based on numbers 3 121
Find and Replace Stream with 0s 8 88
How to build JSON File in Delphi 6 3 96
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question