how to clear dynamically generated checkboxes? lazarus / 61-Beginners ---------------------------------------------------------------------- vks · 2015-03-06 10:17 Hello.. I m creating few checkboxes dynamically based on ComboBox selection. This logic is written inside ComboBox change event. Each time the selection of ComboBox is changed, the old checkboxes are not replaced with the new one, instead the result of the changed selection is appended and displayed below the old checkboxes. Do you suggest me any operations that clears the created checkboxes? ---------------------------------------------------------------------- Leledumbo · 2015-03-06 10:38 Just Free it. But don't do if you call the constructor with non-nil argument. ---------------------------------------------------------------------- Eugene Loza · 2015-03-06 11:01 I usually create all dynamic objects at formcreate and destroy at formclose. Then, just switch parenting (if needed) and visible:=true/false. In your case that would be not creating checkboxes, but assigning captions, checked status & visibility. Also found it useful if a separate procedure makes every checkbox.visible:=false, and then manually set visible:=true for required ones. ---------------------------------------------------------------------- vks · 2015-03-09 07:19 @Leledumbo i use Lazarus IDE v1.2.6 , windows 7..  here is the code that generates the dynamic checkboxes: Code: [Select]N:=DataSource1.DataSet.RecordCount;    for I:=1 to N do    begin    DBCheckBox:=TDBCheckBox.Create(Self);    DBCheckBox.DataSource:=DataSource1;    DBCheckBox.Visible:=False;    CheckBox:=TCheckBox.Create (Self);    CheckBox.Parent := ts_enrol;    CheckBox.Caption := SQLQuery1.FieldByName('Country').AsString;    CheckBox.Top := Top;    CheckBox.Width:=400;    CheckBox.Left := 86 + I*86;    SQLQuery1.Next;    end I need to clear these generated checkboxes on an event(like change in combobox value). how do I do it?. kindly help me out.