Hi
I need to change RichTextBox size in depend of the text in rtf which contains. Is it possible? RichTextBox in .NET 2.0 does not have autosize and I didn't find other way how to do it.
thanks!
Petr
Hi,
Try the following code on RichTextBox controls TextChanged event
private void rt_TextChanged(object sender, EventArgs e)
{
Font tempFont = ((RichTextBox)(sender)).Font;
int textLength = ((RichTextBox)(sender)).Text.Length;
int textLines = ((RichTextBox)(sender)).GetLineFromCharIndex(textL ength) +1;
int Margin = ((RichTextBox)(sender)).Bounds.Height -((RichTextBox)(sender)).ClientSize.Height;
((RichTextBox)(sender)).Height = (TextRenderer.MeasureText(" ", tempFont).Height * textLines) + Margin +2;