Newbie posting, so please revise or move if desired:
What Wes was referring to about freeing objects within a list manually is shown below using a combo box, for example, as a list type item holding objects within itself. class procedure TUtils.FreeAndNilComboBoxObjects(p_cboWork: TComboBox); { Pass in the combo box, and this will clear any objects within the combo box } var nCount: integer; begin for nCount := 0 to (p_cboWork.Items.Count - 1) do begin if (p_cboWork.Items.Objects[nCount] <> nil) then begin p_cboWork.Items.Objects[nCount].free; p_cboWork.Items.Objects[nCount] := nil; end; end; end;
String Grids can hold objects too, here is sample code for nCount := 0 to (p_sgdWork.RowCount - 1) do begin if (p_sgdWork.objects[0,nCount] <> nil) then begin p_sgdWork.objects[0,nCount].free; p_sgdWork.objects[0,nCount] := nil; end; end;
|