PDA

Click to See Complete Forum and Search --> : [Resolved] Printout formating problem


Bongo
Jun 1st, 2005, 11:55 PM
Greetings, how can I make sure that when i printing numbers to paper there
are proper right aligned on a predefined position. e.g. I have a few numbers
which have to be like on a invoice to be printed.

All numbers are decimal numbers and have 2 digits after the decimal.

My idea would be like:

print string to position - (lenght of the string)
where position = fixed value

Many thanks in advance
Manfred

jmcilhinney
Jun 2nd, 2005, 12:01 AM
You can use the Graphics class to measure strings. Then when you print your string you would base the X positon on the alignment border less the width of the string.

Bongo
Jun 2nd, 2005, 12:08 AM
@: jmcilhinney

thx. would you know which member of the class this is?

in the moment I use the following methode to print something.

e.Graphics.DrawString(strAnrede,new Font("Arial",10),new SolidBrush(Color.Black),72,200);

where 72 and 200 the x and teh y position is.

jmcilhinney
Jun 2nd, 2005, 12:27 AM
Lookup the Graphics.MeasureString method, which has several overloads. I would guess that you would use Graphics.MeasureString(String, Font) to measure your string using the intended print font.

Bongo
Jun 2nd, 2005, 01:02 AM
@:jmcilhinney

found it - it works like expected. many thx