如何从textbox类创建验证器或创建新的textbox,而不是从工具箱中拖动textbox
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);
}
3条答案
按热度按时间rpppsulh1#
添加文本框宽度和高度
w8rqjzmb2#
如果我没理解错的话,你想创建一个文本框,并检查文本框中输入的文本是否有效。例如,下面的代码可以用于
textboxUsername
:lfapxunr3#
首先创建此函数:
完成,未找到调用txtPass txtPass_Validating函数