Jump to content
Xtreme .Net Talk

Formatting a List box


Recommended Posts

Posted

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..

 

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?

Posted

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

 

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...

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...