//First, place an error provider component onto the form. It will show up in the components tray. private void txtCustomer_Validating(object sender, CancelEventArgs e) { if (txtCustomer.Text.Trim().Length == 0) { errorProvider1.SetError(txtCustomer,"Please enter customer name."); e.Cancel= true; } else errorProvider1.SetError(txtCustomer, "" ); }