我现在遇到一个问题, 怎样才能在程序运行时动态地为TPageControl 控件加入和删除TTabSheet

解决方案 »

  1.   

    和一般控件差不多,但是除了要指定Parent属性外,还要指定PageControl属性。
      

  2.   

    TMySheet=class(TTabsheet)
            WebBrw:TMyWebBrw;procedure ....
    var
        Tms:TMySheet;
    begin
        if IsAd then
        begin
            cancel:=true;
            exit;
        end;
        Tms:=TMysheet.Create(Mainfrm);//TsgbrwFm is form?
        Tms.PageControl:=Mainfrm.PageControl1;
        Tms.WebBrw:=TMyWebBrw.Create(Mainfrm);
        tms.InsertControl(Tms.WebBrw);
        tms.WebBrw.Align:=alclient;
        Tms.WebBrw.ParentWindow:=Tms.Handle;
        Tms.WebBrw.SetBounds(0,0,Tms.Width,Tms.Height);
        ppDisp:=Tms.WebBrw.DefaultDispatch;
        tms.Width:=tms.Width+1;
        tms.Caption:=title;
        if IsnewOpen  then
        begin
            Mainfrm.PageControl1.ActivePage:=tms;
        end;
    end;