我有一个带有一些文本框和组合框的小表单,每个都有自己的验证事件,当用户移动到下一个框而不输入任何内容时,它只会填充默认值 1 或 0,具体取决于该框,但是我也想要当用户直接单击提交按钮时运行所有验证。
private void Validating_Zero(object sender, CancelEventArgs e)
{
if (((TextBox_Pro)sender).Text == "")
{
((TextBox_Pro)sender).Text = "0";
}
}
private void Validating_One(object sender, CancelEventArgs e)
{
if (((TextBox_Pro)sender).Text == "")
{
((TextBox_Pro)sender).Text = "1";
}
}
private void Start_Validating(object sender, CancelEventArgs e)
{
}
Run Code Online (Sandbox Code Playgroud)