I'm sorry ... I wasn't clear..
I need to check these relatively fast and having to have the mouse directly on the checkbox was problematic so I had coded the on-click event to check or uncheck the box so all I had to do was click the item rather than being right on the checkbox.. but then I had the unintended behavior that when I DO click the checkbox it reverses whatever state so if I click to check it, it checks with the item selection event and then the checkbox unchecks because the checkbox was clicked.
I just got it sorted though .. Also I forgot to mention that I can only select up to 6 items. I did this:
procedure TfMainForm.clbCategoriesClick(Sender: TObject);
var
index:integer;
i:integer;
checked:integer;
begin
checked:=0;
index := clbcategories.itemindex;
clbCategories.Checked[index]:=not clbCategories.Checked[index];
for i:=0 to clbcategories.Count -1 do begin
if clbCategories.Checked[i] then inc(checked);
end;
if checked > options.maxcategories then begin
MessageDlg('Error','You can only select up to ' + options.maxcategories.tostring + ' categories!',mtError,[mbOK],'');
if clbCategories.checked[Index] then
clbCategories.Checked[Index]:=not clbCategories.checked[Index];
end;
end;
and I assigned this to two events - onclick and onclickcheck. Because it runs the same code the checkbox reverses state I guess 3 times. Once for the actual check being clicked, then once for each event. Ultimately it ends up in the state I want it to be in so now I can click either the checkbox or the item and it will limit me to 6 categories.
Rich