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!

List Box Alignment 1

Status
Not open for further replies.

huskerdon

Programmer
Aug 26, 2002
67
US
Hi,

Is there an EASY way to change the alignment of data in a list box. I have a few simple, bound 2-column list boxes on a form, and would just like the columns to be right-justified instead of left-justified. They're just used to display data, and not used for selecting anything. It doesn't matter if the bound column is numeric or text, they always show as left-justified.

It's no big deal, it would just look neater if the values, especially numbers, were right-justified. I'll be putting these on a report also. Why is there an Alignment property, if changing it has no effect?!

I did a search, and found some work-arounds using API's and Style Bits, and don't want to mess with that. If there's no easy way to do it, then I'll just leave it the way it is.

Thanks for any help you may have!

huskerdon
 
Have you considered just using 2 text boxes and set the values to what would display in the list box?
 
dcurtis,

Thanks for the suggestion of using 2 text boxes. That would work, except in the cases where the text boxes would require scroll bars. In that case each of the two boxes would scroll independently, and would not be in sync.

BTW, this is the code I used to populate the text boxes. I haven't used List Boxes very much, so don't know if this is the best method:

Dim x As Byte
Dim strList1 As String
Dim strList2 As String

For x = 0 To (lstBox.ListCount - 1)
strList1 = strList1 & lstBox.Column(0, x) & vbCrLf
strList2 = strList2 & lstBox.Column(1, x) & vbCrLf
Next x

txtCol1 = strList1
txtCol2 = strList2

If I knew that the # of rows would not change, I wouldn't worry about the scrolling issue. However, the number of rows in the source queries can grow, so it might outgtrow the size of the text boxes.

I might keep this idea in mind for use on reports, though.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top