364,033 Members | 4752 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

string formatting

Grant
P: n/a
Grant
Hi,

While iterating through a loop and building a string is it possible to
format certain string value? the completed string eventually gets passed to
a rich TextBox.

for example:

------------------
string thing = "";
foreach (Dataset.Row row in rows)
{
if ( row.name == "whatever" )
{
thing += row.name; //somehow format the
row.name to bold before it goes into the string
}
thing += row.name;
}
-----------------

Possible?


Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


Jon Skeet [C# MVP]
P: n/a
Jon Skeet [C# MVP]
Grant <gpsnett@hotmail.com> wrote:[color=blue]
> While iterating through a loop and building a string is it possible to
> format certain string value? the completed string eventually gets passed to
> a rich TextBox.
>
> for example:
>
> ------------------
> string thing = "";
> foreach (Dataset.Row row in rows)
> {
> if ( row.name == "whatever" )
> {
> thing += row.name; //somehow format the
> row.name to bold before it goes into the string
> }
> thing += row.name;
> }
> -----------------[/color]

The string itself isn't bold or anything similar - you need to work out
how to make it bold in the RichTextBox, i.e. applying rich text
formatting.

I would also suggest using a StringBuilder rather than string
concatenation like the above.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

Post your reply

Help answer this question



Didn't find the answer to your C# / C Sharp question?

You can also browse similar questions: C# / C Sharp