+ -
当前位置:首页 → 问答吧 → delphi里删除文本框控件提示introduced in an ancestor and cannot be deleted

delphi里删除文本框控件提示introduced in an ancestor and cannot be deleted

时间:2011-08-25

来源:互联网

delphi里删除文本框控件提示introduced in an ancestor and cannot be deleted
请各位大侠帮帮忙

作者: artuz   发布时间: 2011-08-25

当前窗体是否为继承后的子类窗体?如果想删除需将父类窗体中的文本框控件删除

作者: cq_mark   发布时间: 2011-08-25

http://hi.baidu.com/ibotj/blog/item/c08c9d715500b3118601b022.html 这里说得很清楚了

作者: varick_zhong   发布时间: 2011-08-25

怎样知道他的父类窗体

作者: artuz   发布时间: 2011-08-25

引用 3 楼 artuz 的回复:
怎样知道他的父类窗体

Delphi(Pascal) code

//递归查找宿主(窗体)
Function GetFrmWithOwner(con:TControl; cnt:integer=0):Tform;
begin
  Result:=nil;
  inc(cnt);
  if con.Owner is TForm then
    Result:=TForm(con.Owner)//返回的就是窗体
  else if cnt<100 then
    Result:=GetFrmWithOwner(TControl(con.Owner),cnt)//找到的Owner不是窗体,则再次递归
  else
    ShowMessage('水太深了!!!'+#13+#13+'递归 100 次,宿主窗体还没浮出。');
end;

//查找一个编辑类的宿主窗体:
var testEdit:TEdit;
begin
  if GetFrmWithOwner(testEdit)<>nil then
    showmessage(testEdit.Name+ ' 的宿主窗体名是:'+GetFrmWithOwner(testEdit).name);
end;

作者: gzzai   发布时间: 2011-08-25

通过上述函数,知道了它的宿主窗体后:
  ShowMessage(宿主窗体.ClassName); {宿主窗体的类名}
  ShowMessage(宿主窗体.ClassParent.ClassName); {宿主窗体的父类名}
  ShowMessage(宿主窗体.ClassParent.ClassParent.ClassName); {宿主窗体的爷爷类名}
通过这些类名,你就可以找到它的父类窗体了

作者: gzzai   发布时间: 2011-08-25

热门下载

更多