E
E
Evgeny Semashko2020-04-14 12:04:54
.NET
Evgeny Semashko, 2020-04-14 12:04:54

How to display tooltip when entering prohibited characters?

private void emailBox_KeyPress(object sender, KeyPressEventArgs e)
    {


        if(!Char.IsLetter(e.KeyChar) && e.KeyChar != 8 && !Char.IsDigit(e.KeyChar) == true)
        {
            e.Handled = true;
            return;
        }
        else if (e.KeyChar < 33 &&  e.KeyChar > 47) // При вводе допустим этих символов tooltip не вылазит

        {
            toolTip1.IsBalloon = true;
            toolTip1.Show("Забыли ввести", this.emailBox, 1000);
        }
    }


It is necessary that the tooltip climbed out, just like when CapsLock was pressed
5e957cace5ec7894921996.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2020-04-14
@evgenysemashko

In WinForms, you can use the ErrorProvider for this.
Practical guide ErrorProvider.
By default, the error is shown as an icon next to the input field.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question