私はフィールドが空であるかどうかをチェックするこのような関数を持っています。空であれば、テキストボックスの横にsetErrorアイコンが表示されます。string.emptyとstring.isnullorempty
private bool ValidateHost()
{
ErrorProvider errorProvider = new ErrorProvider();
bool isValid = true;
//If the txtHost is empty, show a message to user
if(txtHost.Text == string.Empty)
{
errorProvider.SetError(txtHost, "Please enter the host address");
isValid = false;
}
else
errorProvider.SetError(txtHost, string.Empty);
return isValid;
}
が、私は文字列を使用しようとしたとき、isnulloremptyその後、私はSETERRORのアイコンを取得していないです... は、あなたたちはプラザ..このケースでstring.isnulloremptyを使用しての適切な方法が何であるかを教えてもらえます
*あなたはどのように使用しましたか? if(string.IsNullOrEmpty(txtHost.Text))で完全にうまく動作するはずです。 –
"seterrorアイコン"? – annakata