English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

http://i21.photobucket.com/albums/b251/jfindon/format.jpg

There's a picture of what I need the listbox to look like, but I can't seem to get it to format like that with the spaces and indentations. I thought I had to use zones but they aren't working, what's the best way to format output like this?

2007-02-22 06:23:32 · 3 answers · asked by ohok 2 in Computers & Internet Programming & Design

No, it's a list box. The assignment says to use a list box to display the output when the button is clicked.

2007-02-22 06:38:34 · update #1

3 answers

You will have to use a fixed font style like Courier New. Fixed fonts use the same width for all characters. This will make it easier to align your strings into specific columns.

Next you will need to pad strings so they will be a consistent size.

For example you can have a list of items followed by the price.

Consider these two items Hamburger vs Soda. one is 9 characters in lenght while the other is 4 if you concatneate the price to the end of each string Hamburger $2.00 vs Soda $1.00 and each on its own line you will see that the price information doesn't line up.
Hamburger $2.00
Soda $2.00
So if you pad the Item string on the right side with white space so that each item string total lenght is always 20 then you will get the prices to line up. You will also have to format and or pad the prices on the left so as to alway get the decimal points to align.
Hamburger...........$2.00
Soda....................$1.00

All of this padding , formatting and concatenation must be done to a string variable which will then get loaded into the list box as an item.

2007-02-22 07:54:26 · answer #1 · answered by MarkG 7 · 0 0

That probably is a multiline textbox, it would be too difficult to to in a list box. I think the method you want is String.Format(). Learn the format specifiers to do stuff like right-aligned text. For example:

textbox.Text = String.Format("Business Travel Expense\n\nMeals and Entertainment {0,-20}", mealEntertainmentCost)

would print a portion of your example.

2007-02-22 14:39:20 · answer #2 · answered by Pfo 7 · 0 0

That's probably just a mutil-line textbox, not a ListBox.

2007-02-22 14:35:30 · answer #3 · answered by Kryzchek 4 · 0 0

fedest.com, questions and answers