我有“WinForms”和多种表格,希望使用ErrorProvider
关于其中每一部分的内容EDIT:,以检查用户投入是否为“OK”(例如,输入号码在幅度之内......) 在我看来,把这一构成部分从各个形式上删除似乎毫无用处。 如果我做一个
我的想法:
namespace MyApplication {
static class Program {
public static ErrorProvider EP = new ErrorProvider();
...
And then in that individual form to handle Validating
and Validated
events:
private void txtBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
if (txtBox1.Text != "correct text") {
e.Cancel = true;
Program.EP.SetError(txtBox1, "You have error in your input");
...
这种做法是正确的,还是我做些什么?
And if I need more global objects, maybe I should put them all together to some separate static class and in the Program
create just this one (?)
Thanks.