Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Control '' has no parent window

khorsandikhorsandi Member Posts: 11
after running this program:

procedure TForm1.FormCreate(Sender: TObject);
var
WinParent: TWinControl;
cbx: TComboBox;
Panel: tpanel;
begin
WinParent := TWinControl.Create(self);
Panel := tpanel.Create(WinParent);
cbx := TComboBox.Create(Panel);
cbx.Parent := WinParent; //Panel;
cbx.Items.Add('aaa');
end;


show this message : "Control '' has no parent window" .
how can i solve this problem?

thanks.
Mohammad.

Comments

  • zibadianzibadian Member Posts: 6,349
    : after running this program:
    :
    : procedure TForm1.FormCreate(Sender: TObject);
    : var
    : WinParent: TWinControl;
    : cbx: TComboBox;
    : Panel: tpanel;
    : begin
    : WinParent := TWinControl.Create(self);
    : Panel := tpanel.Create(WinParent);
    : cbx := TComboBox.Create(Panel);
    : cbx.Parent := WinParent; //Panel;
    : cbx.Items.Add('aaa');
    : end;
    :
    :
    : show this message : "Control '' has no parent window" .
    : how can i solve this problem?
    :
    : thanks.
    : Mohammad.
    :
    The panel doesn't have a parent, only an owner. Remember:
    - Owner is responsible for the memory management of the control.
    - Parent is the control on which the control is placed.
    For all controls the owner is the form and the Parent can be any TWinControl except itself. Some combinations don't make sense (TEdit as a parent for example), and might not work at all.
Sign In or Register to comment.