Disabling Accept button when the textboxes are empty

This commit is contained in:
Sigmanor 2016-01-20 21:24:04 +02:00
parent 8f84930b80
commit 6f4324cc78
2 changed files with 28 additions and 0 deletions

View file

@ -50,6 +50,7 @@ private void InitializeComponent()
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 0;
this.textBox1.UseSystemPasswordChar = true;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// textBox2
//
@ -58,6 +59,7 @@ private void InitializeComponent()
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 1;
this.textBox2.UseSystemPasswordChar = true;
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// label1
//
@ -79,6 +81,7 @@ private void InitializeComponent()
//
// button1
//
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(182, 82);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);

View file

@ -66,5 +66,30 @@ private void ChangeKeyForm_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0 & textBox2.Text.Length > 0)
{
button1.Enabled = true;
}
else
{
button1.Enabled = false;
}
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0 & textBox2.Text.Length > 0)
{
button1.Enabled = true;
}
else
{
button1.Enabled = false;
}
}
}
}