I have windows app that I am building and want to be able to click one button and select the top 30 entries in a check box control. The select all is easy. Of course I could be overlooking the simplicity here, but it is not making sense right now.
Edited; Here is what I have that works for selecting all entries.
private void ckTop_CheckedChanged(object sender, EventArgs e)
{
// either check all or uncheck all
if (ckTop.Text == "Check all")
{
for (int i = 0; i < CLB.Items.Count; i++) CLB.SetItemChecked(i, true);
ckTop.Text = "Uncheck all";
}
else
{
for (int i = 0; i < CLB.Items.Count; i++) CLB.SetItemChecked(i, false);
ckTop.Text = "Check all";
}
}
I have tried setting the CLB.SetItemChecked(i, true); to a value of 4 to see if it would select the fourth entry, but that did not work.
this should do the trick for you,
for (var i = 0; i < 30; i++)
{
checkedListBox1.SetItemChecked(i, true);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.