winform checkedlistbox 把选中项的值附给textbox控件,只限止选中(勾选的)其中6项

2025-02-27 08:38:23
推荐回答(1个)
回答1:

string checkText = "";
if (checkedListBox1.CheckedItems.Count != 6)
{
MessageBox.Show("必须选择6项");
return;
}

foreach (var item in checkedListBox1.CheckedItems)
{
checkText += item.ToString()+ ";";
}

textBox1.Text = checkText;