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#?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.