Hello,
I am trying to determine which item on a TWebCheckListBox was toggled and I always receive a -1 value regardless of user selection. I am expecting to receive the Index that the user clicked on instead so I can examine the clicked item and do what I need to do.
Here is how the TWebCheckListBox is setup
var
cblPermissions: TWebCheckListBox;
cblPermissions := TWebCheckListBox.Create(Self);
cblPermissions.Name := 'cblPermissions';
cblPermissions.Parent := WebPanel3;
cblPermissions.Left := 366;
cblPermissions.Top := 235;
cblPermissions.Width := 329;
cblPermissions.Height := 273;
cblPermissions.HeightPercent := 100.00000000000000000;
cblPermissions.ItemHeight := 15;
cblPermissions.TabOrder := 6;
cblPermissions.WidthPercent := 100.00000000000000000;
cblPermissions.OnClickCheck := cblPermissionsClickCheck;
And here is the event handler for OnClickCheck:
procedure TfEditUser.cblPermissionsClickCheck(Sender: TObject);
var
Index: Integer;
begin
if Sender is TWebCheckListBox then
begin
Index := TWebCheckListBox(Sender).ItemIndex;
{$IFDEF DEBUG}console.log('cblPermissionsClickCheck: clicked index is ' + Index.ToString);{$ENDIF}
If Index <> -1 then
TRoleStatus(TWebCheckListBox(Sender).Items.Objects[Index]).NewCheckedStatus := TWebCheckListBox(Sender).Checked[Index];
end;
end;
I am not sure how I should do this on TMS Web Core as this same code works on VCL.
If this is not the proper way to do this in Web Core, can you please point me in the right direction?
Thanks,
Alan