いくつかのフィールドを検証したいコードで3つの関数を呼び出しています。以下のコードで作業しようとすると。誤った結果が得られるまで、最初の値のみをチェックします。
fisrt関数がtrueを返す場合は、next関数も呼び出す必要があります。これを行うためにOrOperatorの代わりに使用できるもの。
if (IsFieldEmpty(ref txtFactoryName, true, "Required") ||
IsFieldEmpty(ref txtShortName, true, "Required") ||
IsFieldEmpty(ref cboGodown, true, "Required"))
{ }
編集
public bool IsFieldEmpty(ref TextBox txtControl, Boolean SetErrorProvider,string msgToShowOnError)
{
ErrorProvider EP = new ErrorProvider();
if (txtControl.Text == string.Empty)
{
EP.SetError(txtControl, msgToShowOnError);
return true;
}
else
{
EP.Clear();
return false;
}
}
コメントしてください、このメソッドは、パラメーターの1つとしてref変数を使用して問題ありませんか。
のSubmitイベントの検証をチェックしていwinform
ます。