필자는 필드가 비어 있는지, 또는 비어 있는지, 그리고 비어있는 경우에는 텍스트 상자 옆에 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 아이콘을 못하고 있어요 .. 너희들은 PLZ ..이 경우 string.isnullorempty를 사용하는 적절한 방법이 무엇인지 말해 줄 수
* 어떻게 사용 했습니까? 'if (string.IsNullOrEmpty (txtHost.Text))'와 완벽하게 잘 맞아야합니다. –
"seterror 아이콘"? – annakata