954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

adding items to listbox

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.

Magnusz
Newbie Poster
13 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

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

ptaylor965
Junior Poster
170 posts since Oct 2006
Reputation Points: 16
Solved Threads: 19
 

Thanks ptaylor965. I got it fixed.

Magnusz
Newbie Poster
13 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You