子窗体设为模式窗体,若点击button后并设定dailogresult=dailogresult.ok,则该窗体会自动关闭

private void btn_certain_Click(object sender, EventArgs e)
        {
            //this.DialogResult = DialogResult.OK;
            if (txt_pwd.Text!="")
            {
                string pwd = Encrypt.Encode(txt_pwd.Text);
              

                if (new UserService().loginCheck(Convert.ToInt32(cmb_user.SelectedValue), pwd))
                {
                    _isRight = true;
                    this.Close();
                }

                
                else
                {
                    _isRight = false;
                    lbl_information.Text = lbl_information.Text + "您输入受权密码不正确,请重新输入";

                }

            }
            else
            {
                lbl_information.Text = "";
                lbl_information.Text = "请输入受权密码";
               
            }
        
        }
原文地址:https://www.cnblogs.com/windy3417/p/13944915.html