0

Hey I'm trying to add information to a listbox, but when i try this code it doesn't display it properly.

Dim fmtstr As String = "{0,-10}{1,12}{2,14}"
With lstservices.Items
.Clear()
.Add(String.Format(fmtstr, "Room Rentals", "Half-Day", "Full-Day"))
.Add(String.Format(fmtstr, "1. Standard Rooming", "$32.00", "$65.00"))
.Add(String.Format(fmtstr, "2. Deluxe Rooming", "$72.00", "$144.00"))
End With

I want the results to show under each of the proper category, not all over the place.

Edited by happygeek: fixed formatting

2
Contributors
2
Replies
4
Views
10 Years
Discussion Span
Last Post by Magnusz
1

You will need to add the extra spaces to make up the gaps

Dim fmtstr As String = "{0,-10}{1,12}{2,14}"
With lstservices.Items
    .Clear()
    .Add(String.Format(fmtstr, "Room Rentals        ", "Half-Day ", "Full-Day"))
    .Add(String.Format(fmtstr, "1. Standard Rooming ", "$32.00   ", "$65.00"))
    .Add(String.Format(fmtstr, "2. Deluxe Rooming   ", "$72.00   ", "$144.00"))
End With

and change the font to "Courier New" as the letter 'i' and 'O' use the same amount of space in this font

Votes + Comments
Really Helpful, and clear.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.