In TextBox_Leave event i need to check whether numbers entered in textbox is in serial number or not.If it is not in order then i need to display a message as \"number\" is
One trick is to retain focus in the textbox when trying to leave (with TAB for instance) in case of some condition (missing number):
private void textBox1_Leave(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
if (tb.Text == "3")
tb.Focus();
}
Assuming you are using a standard textbox. You could also use third party controls that where you can cancel an event (e.Cancel = true) on some condition.