List box column alignment

T

Tony

Hi All,

I have a list box that displays two columns. One of the columns holds text,
the other holds integers. What I'd like to do is left align the text column
and right align the interger column. Anyone know if this can be done and if
so, how?

Thanks & Ciao,

Tony
 
B

Bob Hairgrove

Hi All,

I have a list box that displays two columns. One of the columns holds text,
the other holds integers. What I'd like to do is left align the text column
and right align the interger column. Anyone know if this can be done and if
so, how?

Thanks & Ciao,

Tony

In addition to Klatuu's good advice, you will want to use a
fixed-width font (e.g., Courier New) in the list box in order to get
it to display the numbers with the proper alignment.
 
T

Tony

Klatuu,

Thanks for the help. I experimented with, and modified the code, so that it
ended up like this:

"Format([tblTempAcidWaste].[QTY],Space(10-Len(Cstr([tblTempAcidWaste].[QTY])))
& 0) AS QTY "

and followed Bob's suggestion regarding a fixed font and it works well. Now
I just have to find a font that fits with the rest of the UI and work on
spacing. A couple of questions for you, if you don't mind.
1) May I assume that the 0 following the second instance of [IntField] is a
typo? Didn't work when I had it in there but does when it's removed
2) What does the 0 in Format do?

Again, thanks for the help; I appreciate it.

Tony

Klatuu said:
For the column that holds integers, format it so it is a fixed length:
SELECT [TextField], Format([IntField], Space(5 - Len(Cstr([IntField0))) &
"0") FROM SomeTable;
You will have to adjust the column width property and the width of the
list
box to get the visual presentation you want.

Tony said:
Hi All,

I have a list box that displays two columns. One of the columns holds
text,
the other holds integers. What I'd like to do is left align the text
column
and right align the interger column. Anyone know if this can be done and
if
so, how?

Thanks & Ciao,

Tony
 
T

Tony

Hi Bob,

Thanks for pointing this out. I had the code working but until I changed to
a fixed font everything was center aligned & I couldn't figure out what I
was doing incorrectly. Works like a charm now.

Thanks & Ciao,

Tony


Hi All,

I have a list box that displays two columns. One of the columns holds
text,
the other holds integers. What I'd like to do is left align the text
column
and right align the interger column. Anyone know if this can be done and
if
so, how?

Thanks & Ciao,

Tony

In addition to Klatuu's good advice, you will want to use a
fixed-width font (e.g., Courier New) in the list box in order to get
it to display the numbers with the proper alignment.
 
S

Stephen Lebans

You could also have a look here for an alternate solution that works with
any font:
http://www.lebans.com/justicombo.htm
BUG FIX: Feb 01,2002 The CreateIC call was failing on Win NT or higher
systems. I was checking the DC handle returned for >0 where it should have
been <>0!



New Ver 2.1 Justification.zip is a database containing functions to center
and right justify data for List and Combo Boxes.

Major changes for Version 2.1 are:
Use standard API's instead of functions exposed in Access EXE.

Handle Multiple Columns

One Function for both Center and Right Alignment

Support for controls on SubForms

Huge increase in function execution speed

Clean code with comments


New CboRowSeperator.zip is a database containing a functions to display non
selectable Row dividers in a Combo.

My personal thanks to Terry Kreft for his input and assistance with this
upgrade.



Name: Dan Rock

Comments:

Hi,

Just a little addition to your justification.zip

I wanted to show the right justified column in standard number format so i
replaced the below line and it works great!

Thank you much for your contributions to the programming community.

'let's trim the string - better safe than sorry :)

' strText = Trim$(strText)

strText = Trim$(Format(strText, "###,###.00"))


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Tony said:
Klatuu,

Thanks for the help. I experimented with, and modified the code, so that
it ended up like this:

"Format([tblTempAcidWaste].[QTY],Space(10-Len(Cstr([tblTempAcidWaste].[QTY])))
& 0) AS QTY "

and followed Bob's suggestion regarding a fixed font and it works well.
Now I just have to find a font that fits with the rest of the UI and work
on spacing. A couple of questions for you, if you don't mind.
1) May I assume that the 0 following the second instance of [IntField] is
a typo? Didn't work when I had it in there but does when it's removed
2) What does the 0 in Format do?

Again, thanks for the help; I appreciate it.

Tony

Klatuu said:
For the column that holds integers, format it so it is a fixed length:
SELECT [TextField], Format([IntField], Space(5 - Len(Cstr([IntField0))) &
"0") FROM SomeTable;
You will have to adjust the column width property and the width of the
list
box to get the visual presentation you want.

Tony said:
Hi All,

I have a list box that displays two columns. One of the columns holds
text,
the other holds integers. What I'd like to do is left align the text
column
and right align the interger column. Anyone know if this can be done
and if
so, how?

Thanks & Ciao,

Tony
 
T

Tony

Thanks, Stephen.

I came across justicombo on your (bookmarked) website later in the day and
have been tinkering with both to see which fits my needs better.

I appreciate the suggestion.

Ciao,

Tony

Stephen Lebans said:
You could also have a look here for an alternate solution that works with
any font:
http://www.lebans.com/justicombo.htm
BUG FIX: Feb 01,2002 The CreateIC call was failing on Win NT or higher
systems. I was checking the DC handle returned for >0 where it should have
been <>0!



New Ver 2.1 Justification.zip is a database containing functions to center
and right justify data for List and Combo Boxes.

Major changes for Version 2.1 are:
Use standard API's instead of functions exposed in Access EXE.

Handle Multiple Columns

One Function for both Center and Right Alignment

Support for controls on SubForms

Huge increase in function execution speed

Clean code with comments


New CboRowSeperator.zip is a database containing a functions to display
non selectable Row dividers in a Combo.

My personal thanks to Terry Kreft for his input and assistance with this
upgrade.



Name: Dan Rock

Comments:

Hi,

Just a little addition to your justification.zip

I wanted to show the right justified column in standard number format so i
replaced the below line and it works great!

Thank you much for your contributions to the programming community.

'let's trim the string - better safe than sorry :)

' strText = Trim$(strText)

strText = Trim$(Format(strText, "###,###.00"))


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Tony said:
Klatuu,

Thanks for the help. I experimented with, and modified the code, so that
it ended up like this:

"Format([tblTempAcidWaste].[QTY],Space(10-Len(Cstr([tblTempAcidWaste].[QTY])))
& 0) AS QTY "

and followed Bob's suggestion regarding a fixed font and it works well.
Now I just have to find a font that fits with the rest of the UI and work
on spacing. A couple of questions for you, if you don't mind.
1) May I assume that the 0 following the second instance of [IntField] is
a typo? Didn't work when I had it in there but does when it's removed
2) What does the 0 in Format do?

Again, thanks for the help; I appreciate it.

Tony

Klatuu said:
For the column that holds integers, format it so it is a fixed length:
SELECT [TextField], Format([IntField], Space(5 - Len(Cstr([IntField0)))
&
"0") FROM SomeTable;
You will have to adjust the column width property and the width of the
list
box to get the visual presentation you want.

:

Hi All,

I have a list box that displays two columns. One of the columns holds
text,
the other holds integers. What I'd like to do is left align the text
column
and right align the interger column. Anyone know if this can be done
and if
so, how?

Thanks & Ciao,

Tony
 
T

Tony

Stephen,

I ended up using the functions included in justicombo and they work well.
What's really nice is the fact that I'm not limited to a fixed size font.

Again, thanks for the assistance.

Tony

Stephen Lebans said:
You could also have a look here for an alternate solution that works with
any font:
http://www.lebans.com/justicombo.htm
BUG FIX: Feb 01,2002 The CreateIC call was failing on Win NT or higher
systems. I was checking the DC handle returned for >0 where it should have
been <>0!



New Ver 2.1 Justification.zip is a database containing functions to center
and right justify data for List and Combo Boxes.

Major changes for Version 2.1 are:
Use standard API's instead of functions exposed in Access EXE.

Handle Multiple Columns

One Function for both Center and Right Alignment

Support for controls on SubForms

Huge increase in function execution speed

Clean code with comments


New CboRowSeperator.zip is a database containing a functions to display
non selectable Row dividers in a Combo.

My personal thanks to Terry Kreft for his input and assistance with this
upgrade.



Name: Dan Rock

Comments:

Hi,

Just a little addition to your justification.zip

I wanted to show the right justified column in standard number format so i
replaced the below line and it works great!

Thank you much for your contributions to the programming community.

'let's trim the string - better safe than sorry :)

' strText = Trim$(strText)

strText = Trim$(Format(strText, "###,###.00"))


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Tony said:
Klatuu,

Thanks for the help. I experimented with, and modified the code, so that
it ended up like this:

"Format([tblTempAcidWaste].[QTY],Space(10-Len(Cstr([tblTempAcidWaste].[QTY])))
& 0) AS QTY "

and followed Bob's suggestion regarding a fixed font and it works well.
Now I just have to find a font that fits with the rest of the UI and work
on spacing. A couple of questions for you, if you don't mind.
1) May I assume that the 0 following the second instance of [IntField] is
a typo? Didn't work when I had it in there but does when it's removed
2) What does the 0 in Format do?

Again, thanks for the help; I appreciate it.

Tony

Klatuu said:
For the column that holds integers, format it so it is a fixed length:
SELECT [TextField], Format([IntField], Space(5 - Len(Cstr([IntField0)))
&
"0") FROM SomeTable;
You will have to adjust the column width property and the width of the
list
box to get the visual presentation you want.

:

Hi All,

I have a list box that displays two columns. One of the columns holds
text,
the other holds integers. What I'd like to do is left align the text
column
and right align the interger column. Anyone know if this can be done
and if
so, how?

Thanks & Ciao,

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top