Replace line feed in RTF

G

Guest

I am replacing tags with db info. My problem is I some of the addresses do
NOT have an address1. end up with a blank line. I want to get rid of that line

I am using the following code to replace

tempbbb.Rtf = tempbbb.Rtf.Replace("<address1>", newArray.ToString());


<firstName> <lastName>
<address>
<addresss1>
<city>, <state> <zip>

Dear Dave,

This is the letter.

Notice I have line breaks in the text.

If there is no address1 I end up with...

Dave Smith
117 street

mytown, OH 11111



I want

Dave Smith
117 street
mytown, OH 11111

Dear Dave,

This is the letter.

Notice I have line breaks in the text.
 
C

ClayB

Maybe something like this will work:

if(newArray.ToString().Length == 0)
tempbbb.Rtf = tempbbb.Rtf.Replace(Environment.NewLine +
"<address1>", "");
else
tempbbb.Rtf = tempbbb.Rtf.Replace("<address1>",
newArray.ToString());

You may have to examine exactly what your file is using for newline,
and change the Environment.NewLine to be what you find.

=====================
Clay Burch
Syncfusion, Inc.
 

Ask a Question

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.

Ask a Question

Top