Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

right-align a column in ListBox

Status
Not open for further replies.

SuryaF

Programmer
May 21, 2006
100
DE
Hi,
Any ideas how to right-align a column in a listbox? I have some amounts to show and they don't look well when left-aligned.
Thnx.
 
SuryaF,


ReadingOrder Property
You can use the ReadingOrder property to specify or determine the reading order of words in text. Read/write.

expression.ReadingOrder

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks
The ReadingOrder property uses the following settings.

Setting Visual Basic Description
Context 0 Reading order is determined by the language of the first character entered. If a right-to-left language character is entered first, reading order is right to left. If a left-to-right language character is entered first, reading order is left to right.
Left-to-Right 1 Sets the reading order to left to right.
Right-to-Left 2 Sets the reading order to right to left.

You can set this property by using the property sheet or Visual Basic.
In a combo box or list box, the ReadingOrder property determines reading order behavior for both the text box and list box components of the control.
 
DogLover2006, I may be wrong, but I think that property is for some Middle Eastern languages which write from Right to Left as opposed to Left to Right - and as such has nothing to do with alignment.


Hope this helps.

[vampire][bat]
 
You're right earthandfire, the reading order doesn't change the orientation, especially for only 1 column. I guess I'm gonna use some leading spaces to move everything to the right.
Thanks for your answers.
 
With the font set to Courier, the following right-aligns the loan amounts form the loan table.

Code:
SELECT  Space(20-(len( format(LoanAmount,"currency")))) & format(LoanAmount,"currency") FROM tblLoans;

HTH

John
 
If you prefer ListViews then see on of my FAQs
faq702-6025 , faq702-6026 , faq702-6027


________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
As BoxHead implies (by suggesting Courier) using spaces to pad will only reliably work with fixed width fonts. Compare the following (in each case spaces are used to allow for four digits before the decimal point):

(proportional font)
12.34
123.45
98.76
234.56
1234.56
898.98

(fixed width font)[tt]
12.34
123.45
98.76
234.56
1234.56
898.98
[/tt]

whereas in the ListView control as suggested by ZmrAbdulla, the control itself has built in alignment handling (using low level string measurement routines to calculate exact placement regardless of font style).

Hope this helps

[vampire][bat]
 
Thanks a bunch! I was looking for something like a ListView. Your examples ZmrAbdulla are awesome.
Adding leading spaces will not work for me as I don't use a fixed font but the Lebans' example is great, I think I'll be using this one.
This is aweseme, once again thank you all! This place here and all of you really make a difference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top