You can actually set the check state while you're adding the item(s), in
code.
this.checkedLis tBox1.BeginUpda te();
for (int x = 0; x < 25; x++)
{
this.checkedLis tBox1.Items.Add (x.ToString(), CheckState.Chec ked);
}
this.checkedLis tBox1.EndUpdate ();
If you really need to set all the check states after you have added the
items, then you can use the SetItemChecked method.
this.checkedLis tBox1.BeginUpda te();
for (int x = 0; x < 25; x++)
{
this.checkedLis tBox1.Items.Add (x.ToString());
}
for (int x = 0; x < this.checkedLis tBox1.Items.Cou nt; x++)
{
this.checkedLis tBox1.SetItemCh ecked(x, true);
}
this.checkedLis tBox1.EndUpdate ();
--
Tim Wilson
..Net Compact Framework MVP
"Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
news:d54u80$dbs $1@ss405.t-com.hr...[color=blue]
> After I fill checked listbox with data, I would like to checked all items[/color]
in[color=blue]
> list ?
>
> Hrcko
>
>[/color]
"Tim Wilson" <TIM(UNDERSCORE )WILSON(AT)ROGE RS(PERIOD)COM> wrote in message
news:emrlp2yTFH A.3944@tk2msftn gp13.phx.gbl...[color=blue]
> You can actually set the check state while you're adding the item(s), in
> code.
>
> this.checkedLis tBox1.BeginUpda te();
> for (int x = 0; x < 25; x++)
> {
> this.checkedLis tBox1.Items.Add (x.ToString(), CheckState.Chec ked);
> }
> this.checkedLis tBox1.EndUpdate ();
>
> If you really need to set all the check states after you have added the
> items, then you can use the SetItemChecked method.
>
> this.checkedLis tBox1.BeginUpda te();
> for (int x = 0; x < 25; x++)
> {
> this.checkedLis tBox1.Items.Add (x.ToString());
> }
> for (int x = 0; x < this.checkedLis tBox1.Items.Cou nt; x++)
> {
> this.checkedLis tBox1.SetItemCh ecked(x, true);
> }
> this.checkedLis tBox1.EndUpdate ();
>
> --
> Tim Wilson
> .Net Compact Framework MVP
>
> "Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
> news:d54u80$dbs $1@ss405.t-com.hr...[color=green]
>> After I fill checked listbox with data, I would like to checked all items[/color]
> in[color=green]
>> list ?
>>
>> Hrcko
>>
>>[/color]
>
>[/color]
I'm was just loading the CheckedListBox with some data. So you can either
set the check state when you're adding the items to the Items collection or
loop through and set them afterwards. There should be nothing wrong with
"checkedListBox 1.Items.Count" (of course, insert the name of your control).
--
Tim Wilson
..Net Compact Framework MVP
"Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
news:d5a3f9$a4m $1@ss405.t-com.hr...[color=blue]
> What should I put instead of x<25?
>
> I tried listBox.Items.C ount but it doesn't work!
>
> Hrcko
>
>
> "Tim Wilson" <TIM(UNDERSCORE )WILSON(AT)ROGE RS(PERIOD)COM> wrote in message
> news:emrlp2yTFH A.3944@tk2msftn gp13.phx.gbl...[color=green]
> > You can actually set the check state while you're adding the item(s), in
> > code.
> >
> > this.checkedLis tBox1.BeginUpda te();
> > for (int x = 0; x < 25; x++)
> > {
> > this.checkedLis tBox1.Items.Add (x.ToString(), CheckState.Chec ked);
> > }
> > this.checkedLis tBox1.EndUpdate ();
> >
> > If you really need to set all the check states after you have added the
> > items, then you can use the SetItemChecked method.
> >
> > this.checkedLis tBox1.BeginUpda te();
> > for (int x = 0; x < 25; x++)
> > {
> > this.checkedLis tBox1.Items.Add (x.ToString());
> > }
> > for (int x = 0; x < this.checkedLis tBox1.Items.Cou nt; x++)
> > {
> > this.checkedLis tBox1.SetItemCh ecked(x, true);
> > }
> > this.checkedLis tBox1.EndUpdate ();
> >
> > --
> > Tim Wilson
> > .Net Compact Framework MVP
> >
> > "Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
> > news:d54u80$dbs $1@ss405.t-com.hr...[color=darkred]
> >> After I fill checked listbox with data, I would like to checked all[/color][/color][/color]
items[color=blue][color=green]
> > in[color=darkred]
> >> list ?
> >>
> >> Hrcko
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]
Comment