public static class MyExtensions
{
public static bool TextBoxIsEmpty(TextBox txtControl, ErrorProvider eP)
{
if (txtControl.Text == string.Empty)
{
eP.SetError(txtControl, "You must Enter something!");
return true;
}
else
{
eP.Clear();
return false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的项目中使用这个函数来验证一个空文本框。它正常工作,直到我将一个用户控件添加到我的 WinForms 之一。特别是,当 Grid 的数据源更改时,该 User 控件的一个实例会添加到我的表单中,但我收到此错误。
错误 129 调用在以下方法或属性之间不明确:'DominateVehicle.Class.MyExtensions.TextBoxIsEmpty(System.Windows.Forms.TextBox, System.Windows.Forms.ErrorProvider)'和'DominateVehicle.Class.MyExtensions.TextBoxIsEmpty(System .Windows.Forms.TextBox, System.Windows.Forms.ErrorProvider)' D: \Vechel_Dominate\a\DominateVehicle\frmDefectClass.cs 30 41 DominateVehicle
不知道添加用户控件和这个错误有什么关系?如果我删除 UserControl,我的代码将不起作用并且出现错误。我该怎么办?
我想使用Backup该类来备份我的数据库。
Backup backup =new Backup();
但是,我不知道这个类是在哪个命名空间中找到的。
我添加了 Microsoft.SqlServer.SmoExtended.dll 和 Microsoft.SqlServer.Smo.dll
现在它的工作!
谢谢大家