예제 #1
0
 void loginForm1_LoginDelegate(object sender, MyEventArgs e)
 {
     if (e.LoginName == "admin" && e.LoginPwd == "123456")
     {
         e.Result = true;
     }
 }
예제 #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            
            MyEventArgs myEventArgs = new MyEventArgs();
            myEventArgs.LoginName = this.txtName.Text;
            myEventArgs.LoginPwd = this.txtPwd.Text;
            myEventArgs.Result = false;

            //this指的是btnLogin这个控件
            LoginDelegate(this, myEventArgs);

            if (myEventArgs.Result)
            {
                this.txtName.BackColor = Color.Green;
                this.txtPwd.BackColor = Color.Green;
            }
            else
            {
                this.txtName.BackColor = Color.Red;
                this.txtPwd.BackColor = Color.Red;
            }
        }