Home > database >  Validator new textbox c#
Validator new textbox c#

Time:10-25

How to create a validator from the textbox class or create new textbox, rather than dragging the textbox from the toolbox

private void Form1_Load(object sender, EventArgs e)
{
    createTextpass();
    // Creating and setting the properties of TextBox1
    TextBox textboxUsername = new TextBox();
    textboxUsername.Location = new Point(420, 50);         
    textboxUsername.Size = new Size (300,30);
    textboxUsername.Name = "text_user";
    this.Controls.Add(textboxUsername);

    TextBox textboxPassword = new TextBox();
    textboxPassword.Location = new Point(420, 80);
    textboxPassword.Size = new Size(300, 30);
    textboxPassword.Name = "text_pass";
    this.Controls.Add(textboxPassword);

    TextBox textboxMail = new TextBox();
    textboxMail.Location = new Point(420, 110);
    textboxMail.Size = new Size(300, 30);
    textboxMail.Name = "text_mail";
    this.Controls.Add(textboxMail);
}

CodePudding user response:

Add the texbox width and height

CodePudding user response:

At first create this function:
    private void Calltextbox()
     {
         TextBox txtPass = new TextBox();
         txtPass.Location = new Point(80, 60);
         txtPass.AutoSize = true;
         txtPass.Validating  = new CancelEventHandler(txtPass_Validating);
         txtPass.Name = "txtPass";
         Controls.Add(txtPass);
     }

done, txtPass_Validating function called txtPass is not found

  • Related