현재 제품 유지 관리 페이지가있는 데스크톱 응용 프로그램을 개발 중이며 모든 메시지 유효성 검사 오류를 단일 메시지 상자에 표시하는 방법을 찾고 있습니다.단일 메시지 상자에 여러 오류 메시지 표시
나는 아래의 코드를 사용하여 유효성 검사 오류 당 하나의 메시지 상자를 표시하고 (검증은 저장 버튼 바인딩)
if ((Convert.ToInt32(txtQuantity.Text)) > 20000)
{
MessageBox.Show("Maximum quantity is 20,000!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtQuantity.Focus();
return;
}
if ((Convert.ToInt32(txtQuantity.Text)) <= (Convert.ToInt32(txtCriticalLevel.Text)))
{
MessageBox.Show("Quantity is lower than Critical Level.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtQuantity.Focus();
return;
}
if (txtCriticalLevel.Text == "0")
{
MessageBox.Show("Please check for zero values!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtCriticalLevel.Focus();
return;
}
나는 사용자에게 모든 오류를 알 용이성을 제공하고 싶습니다 하나의 메시지 상자 당 하나씩 알기보다는 한 번에.
미리 감사드립니다. :)
감사합니다! –
Concat 문자열이 더 좋을 때 StringBuilder를 사용하십시오 https://msdn.microsoft.com/en-us/library/ms228504.aspx –
코드가 이상하게 작동했습니다. 정말 고맙습니다!! 그러나 당신은 왜 그것의 "더러운"설명 할 수 있었습니까? –