[英]Confirm checked list box
在下面的代碼中,我嘗試向 output 發送一條消息,以確認是否選中了復選框。 我如何檢查每個框?
private void btnRemove_Click(object sender, EventArgs e)
{
//Validate input data
//check if a dvd was entered
//here i want to check to see if any of my check boxes were ticked.
if (chkDVD == "")
{
MessageBox.Show("No DVD Selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//Save data in DVDs File
//Display Confirmation Message
MessageBox.Show("DVD Succesfully removed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
假設您使用的是標准 WinForms 復選框,那么您只需將當前的 if 語句替換為以下行:
if (!chkDVD.Checked)
如果沒有,請發布更多與您擁有的復選框相關的代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.