Users Pricing

forum

Home Forums Spacing in String.Format() – MindStick

Spacing in String.Format()

Jayden Bell 2599 23 Sep 2013

I want fixed spacing between words in a string similar to what you have in a datagrid.

I tried:

string item = String.Format("{0,-9}{1,-42}{2,-24}{3,0}", ++i, itemName, itemQuantity, totalItemPrice.ToString("#,##0.00") + System.Environment.NewLine);

But since the itemName length is varaible itemQuantity and totalItemPrice do not maintain their positions and get pushed forward.


The string is subsequently assigned to a RichTextBox.


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md