Right-align strings within a column

I’m trying to display a record set in vertical arrangement in a DeskTopListbox. The first column contains field labels, one for each row, and the second column contains the corresponding values of the field. I’d like to right-align the labels within their column. For example:

Blockquote

   one 1
   two  2
 three 3
seven 7

How may this be coded in Xojo?
Thanks.

Sorry, the labels one, two, three, seven should be right-aligned in my example.

Maybe you find the documentation helpfull: Desktoplistbox.ColumnAlignmentAt()

ListBox1.ColumnAlignmentAt(1) = DesktopListBox.Alignments.Right

1 Like

Like @Thomas_Roemert wrote. It’s easy and it’s documented.

BTW: You can “design” Tables in this Forum using Markdown.

| Right Aligned | Standard/Left Aligned |
| -----------: | ----------- |
| one | 1 |
| two | 2 |
| three | 3 |
| seven | 7 |

becomes

Right Aligned Standard/Left Aligned
one 1
two 2
three 3
seven 7
3 Likes

Try this in the Open Event of a DesktopListBox:

Me.ColumnCount = 3

Me.ColumnWidths = "*,60,60"

Me.ColumnAlignmentAt(0) = DesktopListBox.Alignments.Right
Me.ColumnAlignmentAt(1) = DesktopListBox.Alignments.Left
Me.ColumnAlignmentAt(2) = DesktopListBox.Alignments.Decimal
Me.ColumnAlignmentOffsetAt(2) = -24

Me.HeaderAt(0) = "Verbal"
Me.HeaderAt(1) = "Whole"
Me.HeaderAt(2) = "Decimal"

Me.AddRow "One", "1", "1,00"
Me.AddRow "Two", "2", "2,00"
Me.AddRow "Three Point Five Two", "3,52", Format(3.52,"#.##") // Using Format to be International savy
Me.AddRow "Seven", "7", "7,00"
Me.AddRow "Twelve", "12", "12,00"

and it will look like this:

Screenshot-1

Is this what you are looking for? :slight_smile:

2 Likes

Yes! Thank you, thank you.

1 Like

It works! Thanks again.

1 Like