Hello,
I have aTAdvSmoothListBox Matrix where I pass some caracteristic to my new aTAdvSmoothListBox created in run time. All the aTAdvSmoothListBoxs are created without any problem, but when I close my form, I have an error, it is an execption where I can't indentify why.
If I call the form without creating the new aTAdvSmoothListBox and close it, it closes it without any problem.
Where could it be?
procedure TFEditorQuestOP.Button3Click(Sender: TObject);
var
ListOpc : TAdvSmoothListBox;
I : Integer;
begin
For I := 0 to 0 do Begin
ListOpc := TAdvSmoothListBox.Create(Application);
ListOpc.Fill := ListMatriz.Fill;
ListOpc.ItemAppearance := ListMatriz.ItemAppearance;
ListOpc.DefaultItem := ListMatriz.DefaultItem;
ListOpc.Cursor := crHandPoint;
ListOpc.Footer.Visible := False;
ListOpc.Name := 'Lst' + IntToStr(i);
ListOpc.Parent := AdvScrollBox1;
ListOpc.Height := 162;
ListOpc.Align := alTop;
ListOpc.Top:= 100;
ListOpc.Header := ListMatriz.Header;
ListOpc.Tag := i;
ListOpc.Visible := True;
ListOpc.Header.Caption := 'Where is Vanessa working this weekend?';
ListOpc.Items.Insert(0);
ListOpc.Items.Items[0].Caption := 'She is not working this weekend.';
ListOpc.Items.Insert(1);
ListOpc.Items.Items[1].Caption := 'She is wth Peter.';
ListOpc.Items.Insert(2);
ListOpc.Items.Items[2].Caption := 'She is at home.';
ListOpc.Items.Insert(3);
ListOpc.Items.Items[3].Caption := 'She is eating an apple.';
ListOpc.Visible := True;
end;
end;
thanks
Change in your code following line:
ListOpc.Fill.Assign(ListMatriz.Fill);
Bruno, I tried to free all component that where created in run time this way:
procedure TFEditorQuestOP.Button4Click(Sender: TObject);
var
ListOpc : TAdvSmoothListBox;
I : Integer;
begin
For I := 0 to 5 do Begin
ListOpc := TAdvSmoothListBox(FindComponent('Lst' + IntToStr(i)));
if Assigned(ListOpc) then ListOpc.free;
end;
end;
But the findcomponent can't find it.
My code works fine with another components, what's wrong?
Bruno, I also changed the others parts and it worked fine, that is, when I close the form I didn't have any exception
ListOpc := TAdvSmoothListBox.Create(Application);
ListOpc.Fill.Assign(ListMatriz.Fill);
ListOpc.ItemAppearance.Assign(ListMatriz.ItemAppearance);
ListOpc.DefaultItem.Assign(ListMatriz.DefaultItem);
ListOpc.ScrollIndicator.Assign(ListMatriz.ScrollIndicator);
ListOpc.Header.Assign(ListMatriz.Header);