Board index » cppbuilder » TCheckListBox - UnCheck all Items

TCheckListBox - UnCheck all Items

Hi,
I am having difficulty with this.
Clear method removes all strings.
ClearSelection only unselects whichever item has focus (if any).
I have been trying to iterate through the items - and change state to
cbUnchecked or set checked to false.
The problem is that accessing the items via the item index returns a string,
not a checklistbox item.
How do I access the item and its state?
Is there not a method that already does this?

Best
Warwick

for( int i = 0; i < CheckListHtml->Count; ++i )
     CheckListHtml->Items[i].State = cbUnchecked;

for( int i = 0; i < CheckListHtml->Count; ++i )
     CheckListHtml->Items[i].Checked  =  false;

both return this error -
 [C++ Error] Unit1.cpp(162): E2316 'State' is not a member of 'TStrings'
 [C++ Error] Unit1.cpp(162): E2316 'Checked' is not a member of 'TStrings'

 

Re:TCheckListBox - UnCheck all Items


Use the Checked[] or State[] property instead:

    for( int i = 0; i < CheckListHtml->Count; ++i )
        CheckListHtml->Checked[i] =  false;

    for( int i = 0; i < CheckListHtml->Count; ++i )
        CheckListHtml->State[i] =  cbUnchecked;

Gambit

Quote
"Warwick" <dhawkm...@xtra.co.nz> wrote in message news:3d336a63$1_2@dnews...
> How do I access the item and its state?
> Is there not a method that already does this?

Re:TCheckListBox - UnCheck all Items


    if ( GivenCondition )
    {
        //Check all
        for ( int i=1; i<=CERTAIN_NUMBER; ++i )
        {
            CKB[i]->Checked = true;
        }
    }
    else
    {
        //Uncheck all
        for ( int i=1; i<=CERTAIN_NUMBER; ++i )
        {
            CKB_SoundOffOn[i]->Checked = false;
        }
    }

Rodolfo

Quote
"Warwick" <dhawkm...@xtra.co.nz> wrote in message news:3d336a63$1_2@dnews...
> Hi,
> I am having difficulty with this.
> Clear method removes all strings.
> ClearSelection only unselects whichever item has focus (if any).
> I have been trying to iterate through the items - and change state to
> cbUnchecked or set checked to false.
> The problem is that accessing the items via the item index returns a
string,
> not a checklistbox item.
> How do I access the item and its state?
> Is there not a method that already does this?

> Best
> Warwick

> for( int i = 0; i < CheckListHtml->Count; ++i )
>      CheckListHtml->Items[i].State = cbUnchecked;

> for( int i = 0; i < CheckListHtml->Count; ++i )
>      CheckListHtml->Items[i].Checked  =  false;

> both return this error -
>  [C++ Error] Unit1.cpp(162): E2316 'State' is not a member of 'TStrings'
>  [C++ Error] Unit1.cpp(162): E2316 'Checked' is not a member of 'TStrings'

Other Threads