Hi Guys!
"can you teach me how to Disable Button Until All Textbox Is Not Empty."
in my design form Named login.
I have 2 textbox and 2 buttons
I want to disable the buttons until all textbox is not empty
i try everything i know but its not working :(
thnks for helping me
so heres my code in c# windows application form
using System.Data.SqlClient;
namespace Online_Examination_System_Finals
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection(@"Data Source=ADMIN-\MSSQLSERVERR;Initial Catalog=Admin;Integrated Security=True");
private void button1_Click(object sender, EventArgs e)
{
SqlDataAdapter sda = new SqlDataAdapter("Select USN From Admin where USN ='" + textBox1.Text + "'and Password ='" + textBox2.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count == 1)
{
this.Hide();
Admin_Panel aa = new Admin_Panel(dt.Rows[0][0].ToString());
aa.Show();
}
else
{
MessageBox.Show("Please check your username and password");
textBox1.SelectAll();
textBox2.Text = "";
}
}
private void button2_Click(object sender, EventArgs e)
{
SqlDataAdapter sda = new SqlDataAdapter("Select USN From Register where USN ='" + textBox1.Text + "'and Password ='" + textBox2.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count == 1)
{
this.Hide();
Student aa = new Student(dt.Rows[0][0].ToString());
aa.Show();
}
else
{
MessageBox.Show("Please check your username and password");
textBox1.SelectAll();
textBox2.Text = "";
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
e.Handled = true;
base.OnKeyPress(e);
}