希望你們一切順利。我想請教你。我正在尋找一種在執(zhí)行 OnClick 按鈕之前驗(yàn)證數(shù)據(jù)的方法。我確實(shí)有一些帶有一些數(shù)據(jù)可供選擇的組合框。目前我使用了一些解決方案,它看起來很“臟”,我對此并不滿意。目前我正在使用類似的東西:if(box1 == null){ MessageBox.Show("Error 1");}if(box2 == null){ MessageBox.Show("Error 2");}if(box3 == null){ MessageBox.Show("Error 3");}如果我有 3 個(gè)字段是空的,我會為每個(gè)錯(cuò)誤顯示 3 次消息。如果錯(cuò)誤為真,有沒有辦法在一個(gè)消息框中列出所有錯(cuò)誤?我在想這樣的事情:bool a = true;bool b = true;bool c = true;a = (box1 == null);b = (box2 == null);c = (box3 == null);if(a || b || c){ //Display list of errors where condition is true}我將不勝感激任何建議。提前謝謝了。
- 2 回答
- 0 關(guān)注
- 160 瀏覽
添加回答
舉報(bào)
0/150
提交
取消