I have several controls in my windows form, namely a Richtextbox and 10 buttons which represents a numpad (from 0-9). When a button is clicked, it will insert the corresponding number into the Richtextbox. I have set the MaxLength property to 6, however i seem to be able to insert more than 6 characters into the textbox by hitting on the buttons. My code is as follows:
private void num1Button_Click(object sender, EventArgs e)
{
richtextbox.Text = richtextbox.Text.Insert(0, "1");
}
Description
So you need to check the length in your code.
Sample
More Information