tags:

views:

284

answers:

1

I am trying to set the MaxLength property on a RichTextBox but it does not seem to work.

Any ideas what might be happening?

A: 

Add this code in yout KeyDown Event.

private void rLetter_KeyDown(object sender, KeyEventArgs e) { TextRange tr= new TextRange(rLetter.Document.ContentStart, rLetter.Document.ContentEnd); if (tr.Text.Length > 4000 || e.Key == Key.Space || e.Key == Key.Enter) { e.Handled = true; return; }

}

I have some problem, The bug is : Test this code using copy and paste text max 4000. Sorry for my English ..