現在、製品保守ページを持つデスクトップアプリケーションを開発中です。すべての検証エラーを1つのメッセージボックスに表示する方法を探しています。複数のエラーメッセージを1つのメッセージボックスに表示
私は以下のコードを使用して検証エラーごとに1つのメッセージボックスを表示しています:(検証は、保存ボタンにバインドされている)
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;
}
私は、ユーザーにすべてのエラーを知るの容易さを与えるしたいのですが表示されたメッセージボックスごとに1つずつ知っているのとは対照的に、
ありがとうございます! :)
これを試してみます、ありがとう!!! –
concat文字列がStringBuilderを使用する方が良い場合https://msdn.microsoft.com/en-us/library/ms228504.aspx –
コードが不思議でした!どうもありがとうございます!!なぜあなたはその「汚い」の理由を説明できますか? –