472,805 Members | 1,105 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

DrawString right aligned

GTi
This must be the simplest question on the web.
How can I right align text with DrawString ?

Normal (left aligned):
1234567890
123456789
12345678
1234567
123456
12345
1234
123
12
1

Right aligned:
1234567890
123456789
12345678
1234567
123456
12345
1234
123
12
1

(it may not look right on some readers)

Jan 21 '06 #1
4 11929
Use one of the overloads of the DrawString method that accepts a
StringFormat and ensure that the Alignment property of the StringFormat
instance is set to Far.

--
Tim Wilson
..NET Compact Framework MVP

"GTi" <tu****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
This must be the simplest question on the web.
How can I right align text with DrawString ?

Normal (left aligned):
1234567890
123456789
12345678
1234567
123456
12345
1234
123
12
1

Right aligned:
1234567890
123456789
12345678
1234567
123456
12345
1234
123
12
1

(it may not look right on some readers)

Jan 22 '06 #2
GTi
Yeeeeh -
Why do they have to change it to near / far ???
Whats wrong with left/right and top/bottom?
Only to make old dogs more confused ?

Jan 22 '06 #3
The StringFormat class also has a LineAlignment property that uses the
StringAlignment enum. The LineAlignment is the vertical alignment. So it
would be top, middle, and bottom. However, by calling the enum values near,
center, and far they can reuse this enum across both alignment properties.
Used in the context of the LineAlignment property the "far" value would mean
bottom. There is also the notion of left-to-right versus right-to-left
layout. So based on the layout, "far" means the opposite side, or far side,
from the origin position, which could be left or right depending on the
layout. I'm in no way attempting to defend this decision, nor am I stating
that these are the reasons why it was done. I'm merely stating that these
might be possible reasons for this naming decision.

--
Tim Wilson
..NET Compact Framework MVP

"GTi" <tu****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Yeeeeh -
Why do they have to change it to near / far ???
Whats wrong with left/right and top/bottom?
Only to make old dogs more confused ?

Jan 22 '06 #4
I believe "near" and "far" were chosen to provide compatibility with
right-to-left (RTL) languages such as Hebrew and Arabic. For example,
"near" means to align the text to the left edge in a Left-to-right
language, and align to the right on a RTL language.

However, this use of near and far is not consistent across the .NET
platform; see Control.RightToLeft property
(http://msdn.microsoft.com/library/de...oLeftTopic.asp)
and its interaction with child control's HorizontalAlignment
properties.

-- Tim Scott
http://geekswithblogs.net/tscott

Jan 22 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Marek Mand | last post by:
How to create a functional *flexible* UL-menu list <div> <ul> <li><a href=""></li> <li><a href=""></li> <li><a href=""></li> </ul> </div> (working in IE, Mozilla1.6, Opera7 (or maybe even...
1
by: David Lindgren | last post by:
Hello! I am using the DrawString method with different StringAlignments passed to it and the result varies alot! Take a look at this screenshot:...
6
by: Sam Sungshik Kong | last post by:
Hello! I'm testing Graphics.DrawString and it's very strange. I created an event handler for the form.s Paint event. (There's no other code in the form.) private void Form1_Paint(object...
19
by: JB | last post by:
Hi All, Why doesn't this work in Firefox but is perfect in IE6? In IE6, the text is on the same line but in Firefox, the left aligned text is on the line above the right aligned text. ...
3
by: Sjef Janssen | last post by:
Is it possible to have a box (div) which sets a background-color and which contains (on the same line) text which is left aligned and text which is right aligned. (as in a table: two td's left one...
2
by: ChrisNightingale | last post by:
Hi everybody, I have an odd issue which I'm not sure how to resolve. I'm basically implementing a print mechanism which takes a series of controls and reproduces them on a print document. So...
2
by: Siv | last post by:
Hi, I want to print using the Graphics.Drawstring method but instead of using either bold or underline I want to combine both so the printed text is bold and underline?? The way I send the...
4
by: Sin Jeong-hun | last post by:
Hello. It seems like the default behavior of DrawString is trying to keep the whole word if possible. I'd like the string to be drawn in multilines, but filling the entire line width. For example...
9
by: kynos | last post by:
I would like to paint a box using DrawString, standard Unicode characters (box drawings characters) and monospaced font. Unfortunately for some fonts painted lines contain a break. Example...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.