引发错误时如何将焦点设置到文本框 [英] How to set the focus to the text Box when the error throws
本文介绍了引发错误时如何将焦点设置到文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当错误抛出时,我想将焦点设置到文本框.我正在从其他类中调用该类.这是代码
Hi,
I want to set a focus to the text box when the error throws. I am using calling this class from some other class.Here is the code
public string CustomerSubmission
{
get
{
return _customerSubmission;
}
set
{
try
{
DateTime CustomerSubmission = Convert.ToDateTime(UserUtil.ConvertDate(value.ToString().Trim()));
if (value.ToString().Trim() == "")
{
throw new Exception(Message.Blank("Customer Submission Date"));
}
else if (!UserUtil.IsDateinDDMMYYYYFormat(value))
{
throw new Exception(Message.InvalidDate("Customer SubmissionDate"));
}
else if (CustomerSubmission > DateTime.Now)
{
throw new Exception(Message.DateShouldBeLessThan("Customer Submission Date"));
}
_customerSubmission = UserUtil.ConvertDate(value.ToString().Trim());
}
catch (Exception ex)
{
throw;
}
}
}
预先感谢
Thanks in advance
推荐答案
尝试使用TextBox.Focus方法-如果这是Winforms,那么它将起作用.
Try the TextBox.Focus method - if this is Winforms then it will work.
这篇关于引发错误时如何将焦点设置到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文