winform checkedlistbox 任意最多选中其中6项,怎么限止6项呢
privatevoidchbBreakDown_SelectedValueChanged_1(objectsender,EventArgse){strings=strin...
private void chbBreakDown_SelectedValueChanged_1(object sender, EventArgs e)
{
string s = string.Empty;
for (int i = 0; i < chbBreakDown.Items.Count; i++)
{
if (chbBreakDown.GetItemChecked(i))
{
if (s == string.Empty)
{
s = chbBreakDown.GetItemText(chbBreakDown.Items[i]);
}
else
{
s = s + "," + chbBreakDown.GetItemText(chbBreakDown.Items[i]);
}
}
}
txtbreakdown.Text = s;
} 展开
{
string s = string.Empty;
for (int i = 0; i < chbBreakDown.Items.Count; i++)
{
if (chbBreakDown.GetItemChecked(i))
{
if (s == string.Empty)
{
s = chbBreakDown.GetItemText(chbBreakDown.Items[i]);
}
else
{
s = s + "," + chbBreakDown.GetItemText(chbBreakDown.Items[i]);
}
}
}
txtbreakdown.Text = s;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询