G
Guest
I need to format a string so it appears as columns in a ListBox. Of course if I use \t then the columns don't necessarily line up. Is there iomanip style functions for fomatting strings in C#?
course if I use \t then the columns don't necessarily line up. Is thereEric said:I need to format a string so it appears as columns in a ListBox. Of
format the string. For example, here's how 2 records might format if I useEric said:Yeah, it is getting it from an overridden method but I need to know how to
format the string. For example, here's how 2 records might format if I useEric said:Yeah, it is getting it from an overridden method but I need to know how to
Vanessa said:Hi Chris,
Thank you for improving upon my suggestion. I wasn't aware of the
formatting options you have indicated.
Perhaps you might have an answer to this:
There is the option of coding ToString(" ####.##")
Is there also someting like ToString("/ / ####.##")
to accomodate strings as well? I found no references in MDSN.
V.
Note that this relies on using a font such as Courier New, which has equally
spaced characters:
string.Format( "{0,-19}{1,-19}{2,-10}{3,-12}", list[i,0], list[i,1],
list[i,2], list[i,3] )
First Last Number MoreInfo
VeryLongFirstName Last Number MoreInfo
Otherwise, you'll get something like this (Arial):
First Last Number MoreInfo
VeryLongFirstName Last Number MoreInfo
Chris A.R.
toEric said:Yeah, it is getting it from an overridden method but I need to know how
format the string. For example, here's how 2 records might format if I use
\t. The columns don't line up.First Last Number MoreInfo
VeryLongFirstName Last Number MoreInfo
Chris A. R. said:Vanessa,
I'm not quite sure what you're asking for here. How about giving an example
of what you would like to start with and what you would like to finish with
in some pseudo-code and I'll see if I can answer your question.
Chris A.R.
howVanessa said:Hi Chris,
Thank you for improving upon my suggestion. I wasn't aware of the
formatting options you have indicated.
Perhaps you might have an answer to this:
There is the option of coding ToString(" ####.##")
Is there also someting like ToString("/ / ####.##")
to accomodate strings as well? I found no references in MDSN.
V.
Note that this relies on using a font such as Courier New, which has equally
spaced characters:
string.Format( "{0,-19}{1,-19}{2,-10}{3,-12}", list[i,0], list[i,1],
list[i,2], list[i,3] )
First Last Number MoreInfo
VeryLongFirstName Last Number MoreInfo
Otherwise, you'll get something like this (Arial):
First Last Number MoreInfo
VeryLongFirstName Last Number MoreInfo
Chris A.R.
Eric said:Yeah, it is getting it from an overridden method but I need to knowto
format the string. For example, here's how 2 records might format if I use
\t. The columns don't line up.