Reputation: 49
I'm trying to format my listbox so that it looks neat when its in use.
I want to add dollar signs to my numbers, and left align them. Any help would be appreciated. They currently look really sloppy.
Dim salesTotal As Double
customerListBox.Items.Add("Customer: " & " " & "Total Sale: ")
For Each record As DataRow In Me._442_Project_Part_2DataSet.Customers
salesTotal += Double.Parse(CStr(record.Item("YTDSales")))
customerListBox.Items.Add((CStr(record.Item("CustomerName"))) & " " & (CStr(record.Item("YTDSales"))))
customerListBox.Items.Add("------------------------------------------------")
Next
Upvotes: 1
Views: 641
Reputation: 6649
First of all ListBox arn't meant to be easily customizable.
To answer your question I want to add dollar signs to my numbers, and left align them
, you need to use String.PadLeft
function.
customerListBox.Items.Add((CStr(record.Item("CustomerName"))) & " : $" & (CStr(record.Item("YTDSales"))).PadLeft(8))
Note : I added 8 spaces in this exemple. It might vary depending on the numbers you have. I also added a colon and dollar sign between CustomerName and Sales.
Upvotes: 2