Board index » cppbuilder » TCheckListBox - Problems checking items

TCheckListBox - Problems checking items

Hi folks.

Using Borland C++ Builder Pro 5, I have a standard TCheckListBox, and adding
items is easy. Checking if they're selected is also easy using the
Selected-property.

According to the help-file, I can use the Selected-property to set the value
as well, meaning that I should be able to check boxes by means of simple
C++-calls. However, this doesn't work.

Example:

    if(Entries->Selected[Counter])
    {
        Criteria++;

This one works just fine, i.e. using the Selected property to check if an
item in the list is selected or not is perfectly easy. Now, I'm trying to
create a "Select All"-button, which should be a walk in the park according
to the help file. However, when I try this:

    for(int Counter = 0; Counter < Entries->Items->Count; Counter++)
    {
        Entries->Selected[Counter] = true;
    }

the application exits the loop at the very first call, saying "List Index
Out of Bounds (0)". What am I doing wrong?

Furthermore, in the help-file, there doesn't seem to be any methods for
selecting items in a TCheckListBox.
Can someone suggest an alternative or tell me if I'm just being a lamer/
idiot?

Please CC to my e-mail at christ...@vizionfactory.dk, thank you.

Kind regards,
Christian Jahnsen

 

Re:TCheckListBox - Problems checking items


Do you have the listbox set as MultiSelect? I think this might make a
difference. I believe that you use ItemIndex if MultiSelect is false.

--
Rgds Pete
GenHelp: The Component Writers Help Authoring package
=================================
Web:  www.frasersoft.net

Quote
"Christian Jahnsen" <christ...@vizionfactory.dk> wrote in message

news:3d638283@newsgroups.borland.com...

Quote
> Hi folks.

> Using Borland C++ Builder Pro 5, I have a standard TCheckListBox, and
adding
> items is easy. Checking if they're selected is also easy using the
> Selected-property.

> According to the help-file, I can use the Selected-property to set the
value
> as well, meaning that I should be able to check boxes by means of simple
> C++-calls. However, this doesn't work.

<snip>

Re:TCheckListBox - Problems checking items


You should be using the Checked[] property instead of Selected[] to change
the checkboxes.

Gambit

P.S. please don't cross-post, it is against Borland's newsgroup guidelines.
Only post questions to the single most appropriate group, which in this case
is the vcl.components.using group.  This is not an issue regarding writing
new components, which is what this group is for.

Quote
"Christian Jahnsen" <christ...@vizionfactory.dk> wrote in message

news:3d638283@newsgroups.borland.com...
Quote
> Now, I'm trying to create a "Select All"-button, which
> should be a walk in the park according to the help file.

Other Threads