There are 10 controls, there is one errorprovider . If there is no text in the control, a message appears

  errorProvider1.SetError(extensionNumBox, "Поле «Добавочный номер» обязательно для заполнения"); 

Everything is fine, but the error icon remains, but I would like it to blink for about 5 seconds, then the alert disappeared. If i do like this

  errorProvider1.SetError(extensionNumBox, ""); 

So I do not have time to display the error itself.

  • What graphic framework are you using? - VladD
  • in the sense of the framework? - Rajab
  • one
    Well, in C #, there is no concept errorprovider. Since you are talking about controls and text, therefore, you use some kind of graphical framework, to which, apparently, the concept of errorprovider refers. Since you did not specify your framework in the labels, I asked again. - VladD
  • System.Windows.Forms.ErrorProvider - Radzhab
  • Use a timer or await Task.Delay() . They pressed the button, filled the ErrorProvider , started the timer / waited, cleared the ErrorProvider for all controls. - andreycha

1 answer 1

Use the timer or await Task.Delay() :

  1. ErrorProvider .
  2. We started the timer / waited.
  3. Clear ErrorProvider for all controls (if you use a timer, do not forget to use Invoke , since the callback timer is not called in the UI thread).

Example using Task.Delay() :

 private async void btnValidate_Click(object sender, EventArgs e) { Validate(); await Task.Delay(TimeSpan.FromSeconds(5)); ClearValidation(); } private void Validate() { if (string.IsNullOrEmpty(extensionNumBox.Text)) { errorProvider1.SetError( extensionNumBox, "Поле «Добавочный номер» обязательно для заполнения"); } // другие проверки } private void ClearValidation() { errorProvider1.SetError(extensionNumBox, string.Empty); // очищаем другие контролы }