private void txtCategoryCode_TextChanged(object sender, EventArgs e) { txtCategoryCode.KeyPress += new KeyPressEventHandler(MyKeyPress); } void MyKeyPress(object sender, KeyPressEventArgs e) { TextBox txt = sender as TextBox; if (txt.Text.Length > 3) { e.Handled = true; MessageBox.Show("Category Code should be in 3 letters.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
this.txtCategoryCode.Keypress +=new EventHandler(txtCategoryCode_KeyPress);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)