Click here to Skip to main content
16,004,977 members
Home / Discussions / C#
   

C#

 
QuestionTablet PC Handwriting recognizer: Urgent Pin
bibhakar1-Nov-07 0:31
bibhakar1-Nov-07 0:31 
AnswerRe: Tablet PC Handwriting recognizer: Urgent Pin
m@u1-Nov-07 0:52
m@u1-Nov-07 0:52 
QuestionResizable control question Pin
adt_brauer1-Nov-07 0:30
adt_brauer1-Nov-07 0:30 
AnswerRe: Resizable control question Pin
Matthew Butler1-Nov-07 6:12
Matthew Butler1-Nov-07 6:12 
Questionproblem with drawString() Pin
arnoldpinto841-Nov-07 0:21
arnoldpinto841-Nov-07 0:21 
AnswerRe: problem with drawString() Pin
Luc Pattyn1-Nov-07 3:55
sitebuilderLuc Pattyn1-Nov-07 3:55 
GeneralRe: problem with drawString() Pin
arnoldpinto841-Nov-07 20:06
arnoldpinto841-Nov-07 20:06 
GeneralRe: problem with drawString() Pin
Luc Pattyn2-Nov-07 15:32
sitebuilderLuc Pattyn2-Nov-07 15:32 
Hi,

Graphics.DrawString() will paint a string at the given coordinates (specified by either
a PointF or two floats, and indicating the top-left corner as always).

So it is up to you to specify the right x-value to get the alignment you want.
There are two possibilities:

1. using a non-proportional font, such as Courier New, where all symbols have the same width:
you can simply keep x constant and adjust the string, i.e. add spaces to the left and/or
the right, so the characters appear where you want them.

2. using an arbitrary font:
since character widths may vary now, you must find out how wide a specific string is,
and then adjust the x-value to get it to align properly.
The width can be obtained from Graphics.MeasureString(). Be careful to specify the
same parameters (text, font, brush, ...) you are going to pass to DrawString() later on.
If you want the unit digits to align, you should split the string in two parts, the left one
ending on the unit digit, the right one holding everything else (could be decimal point,
decimals, and/or a closing parenthesis). Then calculate the width of the left part,
and adjust it's x-value accordingly. The right part will have to be drawn at a constant
x-value, since that one needs to be aligned.
As you can see, with arbitrary fonts, spaces don't really come into the solution.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]


this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google


GeneralRe: problem with drawString() Pin
arnoldpinto844-Nov-07 19:13
arnoldpinto844-Nov-07 19:13 
QuestionProblem Working with Created Local User Pin
narayanagvs1-Nov-07 0:06
narayanagvs1-Nov-07 0:06 
Questionh323 call answer Pin
sima_m1-Nov-07 0:04
sima_m1-Nov-07 0:04 
QuestionHow to prevent cnt+f4 key,,,? Pin
Pankaj - Joshi31-Oct-07 23:47
Pankaj - Joshi31-Oct-07 23:47 
AnswerRe: How to prevent cnt+f4 key,,,? Pin
Colin Angus Mackay1-Nov-07 1:44
Colin Angus Mackay1-Nov-07 1:44 
AnswerRe: How to prevent cnt+f4 key,,,? Pin
DannyAdler1-Nov-07 3:17
DannyAdler1-Nov-07 3:17 
GeneralIt is working.... Pin
Pankaj - Joshi1-Nov-07 19:23
Pankaj - Joshi1-Nov-07 19:23 
GeneralRe: It is working.... Pin
DannyAdler3-Nov-07 23:22
DannyAdler3-Nov-07 23:22 
QuestionFailure sending mail Pin
DannyAdler31-Oct-07 23:39
DannyAdler31-Oct-07 23:39 
AnswerRe: Failure sending mail Pin
Christian Graus1-Nov-07 0:25
protectorChristian Graus1-Nov-07 0:25 
AnswerRe: Failure sending mail Pin
duncanmhor1-Nov-07 1:34
duncanmhor1-Nov-07 1:34 
QuestionPaste table from Word file into RichTextBox problem [modified] Pin
nesaver8531-Oct-07 22:49
nesaver8531-Oct-07 22:49 
AnswerRe: Paste table from Word file into RichTextBox problem Pin
mav.northwind1-Nov-07 7:33
mav.northwind1-Nov-07 7:33 
QuestionDataGridView CellStyle Pin
half-life31-Oct-07 21:58
half-life31-Oct-07 21:58 
QuestionProblem with the link ! Pin
whale8431-Oct-07 21:37
whale8431-Oct-07 21:37 
AnswerRe: Problem with the link ! Pin
pmarfleet1-Nov-07 0:04
pmarfleet1-Nov-07 0:04 
GeneralRe: Problem with the link ! Pin
whale841-Nov-07 6:06
whale841-Nov-07 6:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.