Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 WinForms 对话框,其中正在验证我的控件并在其验证方法中调用ErrorProvider's ,但我的表单方法仍然始终返回 true。为什么?SetErrorValidateChildren
ErrorProvider
SetError
ValidateChildren
您需要设置传递给验证方法Cancel的对象的属性:CancelEventArgs
Cancel
CancelEventArgs
private void SinglePromptField_Validating(object sender, CancelEventArgs e) { this.errorProvider.SetError(this.control, "Invalid value!"); e.Cancel = true; }