0
我有一個驗證事件用winform的控件箱[X]跳過驗證?
private void EmployeeIDtextBox_Validating(object sender, CancelEventArgs e)
{
if (EmployeeIDtextBox.Text == "")
{
MessageBox.Show("Please Enter EmployeeID.", "Invalid EmployeeID");
}
}
,並能夠跳過驗證了cancelbutton
private void cancelbutton_Click(object sender, EventArgs e)
{
AutoValidate = AutoValidate.Disable;
Close();
}
是否有可能跳過與windowsform的控制盒[X]驗證?我試圖將CausesValidation的形式設置爲false,但它不起作用。我也嘗試與formclosing,但它不工作。
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (EmployeeIDtextBox.CausesValidation)
{
EmployeeIDtextBox.CausesValidation = false;
Close();
}
}
在FormClosing中使用與cancelbutton_Click中相同的代碼。 – wonko79 2013-05-14 13:07:16
我已經試過了,但沒有工作:( – 2013-05-14 13:13:48