Formatting a List box

  • Thread starter Thread starter Danno
  • Start date Start date
D

Danno

Guest
I have a string and variable that I am trying to get added into a ListBox and trying to format it to no avail. Here is a sample..

Code:
totalCost = ((Convert.ToInt32(txtYears.Text) * 12) - 1) * payment

lstDisplay.Items.Add(String.Format("{0,7}", "Total amount paid over " & txtYears.Text & " years:  " & FormatCurrency(totalCost)))

and although it puts the concantenated string into the listbox, no matter what I do the string will not format (stays on the left border).

Any Suggestions?
 
I need to modify the post. The actual code was:

Code:
lstDisplay.Items.Add([B]String.Format[/B]("{0,7}", "Total amount paid over " &_
txtYears.Text & " years:  " & FormatCurrency(totalCost)))


I did a carriage return on this with the "_" so that it won't scroll off the page...
 
I will try it this evening....the end result string should say something like:

Total amount paid over 14 years: $250,000

Will your solution do that? Is it the string, followed by the formatting, a comma and then the other variable?
 
Back
Top