I would like to populate the items in a CheckListEdit component using the following code. I added a button and an additional CheckListEdit to the CheckListEdit demo, and the following code for the button's OnClick event. When I click on the button the items are loaded into the CheckListEdit. If I view the items or check an item or two, and then click on the button again I get an error indicating that the "Control has no parent window".
procedure TForm1.Button1Click(Sender: TObject);
var stringlist : Tstringlist;
begin
stringlist:=TStringList.Create;
stringlist.Add('Item1');
stringlist.Add('Item2');
stringlist.Add('Item3');
try
CheckListEdit4.Items := stringlist;
finally
stringlist.Free;
end;
end;
I tried adding the following prior to the "try finally" statement, but the error persists.
CheckListEdit4.ClearSelection;
CheckListEdit4.Items.Clear;
CheckListEdit4.Clear;
CheckListEdit4.Parent := self;
CheckListEdit4.SetFocus;
I would appreciate any ideas for correcting this error. In the actual application the stringlist can change and I want to update the CheckListEdit items when this happens. Thanks.
Paul