From 6f4324cc78b300ac10bdc7db15d43e8294dfce33 Mon Sep 17 00:00:00 2001 From: Sigmanor Date: Wed, 20 Jan 2016 21:24:04 +0200 Subject: [PATCH] Disabling Accept button when the textboxes are empty --- Crypto Notepad/ChangeKeyForm.Designer.cs | 3 +++ Crypto Notepad/ChangeKeyForm.cs | 25 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Crypto Notepad/ChangeKeyForm.Designer.cs b/Crypto Notepad/ChangeKeyForm.Designer.cs index 0421b8f..8620e03 100644 --- a/Crypto Notepad/ChangeKeyForm.Designer.cs +++ b/Crypto Notepad/ChangeKeyForm.Designer.cs @@ -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); diff --git a/Crypto Notepad/ChangeKeyForm.cs b/Crypto Notepad/ChangeKeyForm.cs index bde6a07..090a75f 100644 --- a/Crypto Notepad/ChangeKeyForm.cs +++ b/Crypto Notepad/ChangeKeyForm.cs @@ -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; + } + } + } }