title: C# Winforms RichTextBox. How to limit number of characters by size of rtb?
body: <p>How to limit number of characters by size of rtb? The same question for WPF textbox.</p>
  
  <p>I tried to limit it by compare clientSize of rtb with <code>Graphics.MeasureString</code> and <code>TextRenderer.MeasureText</code>, but their both have some mistake in calculations, and <code>TR.MeasureText</code> cannot wrap one long word as rtb. So I have a big problem with long words.</p>
  
  <p>In WPF I used <code>FormattedText</code> to get text size, but it also doesn't wrap long words.</p>
  
  <p>About the logic: in paste command I tried to make Adobe Acrobat logics for text fields: when you paste long text in middle of other text, you paste only that number of chars which you can.</p>
  
  <p>Sorry for my language.</p>