how to remove blank lines from richbox
<p>I have several blank line in my richbox and I need to remove them from rich. </p>

<p>I can fine blank lines but can't remove them. how can I do it? I used this code but it didn't work:</p>

<pre><code>RichTextBox rtfBox = new RichTextBox();
rtfBox.Rtf = SOME NTEXT DATA;

int lineNumber = 0;
foreach (string a in rtfBox.Lines)
{
    if (a == "")
    {
        int start_index = rtfBox.GetFirstCharIndexFromLine(lineNumber);
        int countLineChar = rtfBox.Lines[lineNumber].Length;
        // Eat new line chars
        if (lineNumber &lt; rtfBox.Lines.Length - 1)
        {
            countLineChar += rtfBox.GetFirstCharIndexFromLine(lineNumber + 1) -
                ((start_index + countLineChar - 1) + 1);
        }
        rtfBox.Text = rtfBox.Text.Remove(start_index, countLineChar);
    }
    else
        lineNumber++;
}
</code></pre>

<p>this line <code>rtfBox.Text = rtfBox.Text.Remove(start_index, countLineChar);</code> don't work.</p>

<p>thanks</p>

<p><strong>Update</strong></p>

<p>Thanks everybody, your suggestion are useful when richbox content is just text, but I have image and table in my rich too. when I use rtb.Text = or rtfBox.Text = or richTextBox1.Text = images and tables will be remove from richbox.</p>
