Dar*_*ght 1 .net c# validation
我正在验证如下所示的文本框,假设在单击"确定"后会弹出覆盖带有无效数字消息的文本框条目,我希望显示之前覆盖的有效条目.
我怎么能在C#中做到这一点?
private void cor_o_gain_Validating(object sender, CancelEventArgs e)
{
try
{
int entered = int.Parse(cor_o_gain.Text);
if (entered > 255)
{
e.Cancel = true;
MessageBox.Show("Enter the number between 0 and 255");
}
}
catch (FormatException)
{
// e.Cancel = true;
}
}
Run Code Online (Sandbox Code Playgroud)