Hello, I'm relatively new in using pascal. School requires me to do a project and I want to use a dynamically created component(TEdit in this case). But I want it to be deleted/removed in some conditions, I have tried freeandnil but it didn't work, how can I do it?
procedure TForm2.ComboBox1Change(Sender: TObject);
var
devEdit: TEdit;
begin
case ComboBox1.ItemIndex of
0: FreeAndNil(devEdit);
1: FreeAndNil(devEdit);
2: FreeAndNil(devEdit);
3: FreeAndNil(devEdit);
4: FreeAndNil(devEdit);
5: begin
devEdit := TEdit.Create(self);
devEdit.parent := Form2;
devEdit.width := 150;
devEdit.height := 100;
devEdit.font.size := 16;
devEdit.left := 192;
devEdit.top := 40;
end;
end;
end;
I want the TEdit to appear when Itemindex is 5 and I want it to disappear when itemindex is not 5.
Thanks for helping.