自制组件出现问题,无法将组件放置到窗体中。“Control ''has no parent window.”,这是为何?
有哥 2002-07-05 10:09:36 我从TWinControl派生的,在只有一个StringGrid时是正常的,我的测试程序未曾删除过它,一直正常运行至今。现在感觉差不多了,想把它实际运用到最终程序中,添加此组件时,却出现上述提示框,无法添加到窗体中。
即使在一直正常运行着的测试程序中也无法加入,但最初添加的那个却能正常工作。
我估计是可能是组件的构造函数有问题,但又不明白哪儿有错,希望高手帮我看看。
__fastcall THGrid::THGrid(TComponent* Owner)
: TWinControl(Owner)
{
Grider=new TStringGrid(this);
Combo=new TComboBox(this);
Header=new THeaderControl(this);
Editor=new TEdit(this);
ma= Header->Sections->Add();
ma->Text = "材料";
mb= Header->Sections->Add();
mb->Text = "数量";
mb->AutoSize =true;
Grider->Parent=this;
Header->Parent=this;
Editor->Parent=this;
Combo->Parent=this;
Editor->Visible =false;
Header->Visible =true;
Header->Align=alTop ;
Header->Style =hsFlat ;
Combo->Visible =false;
Editor->OnExit=FOnEditorLeave;
Grider->OnEnter=FOnGridEnter;
}