Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread TPagePanel
Sat, Oct 5 2024 6:18 PMPermanent Link

Artur2024

Avatar

How to programmatically remove Pages from TPagePanel and how to add new Pages?

Thank you
Sat, Oct 5 2024 7:32 PMPermanent Link

erickengelke

Avatar

Artur2024 wrote:

> How to programmatically remove Pages from TPagePanel and how to add new Pages?

Here's the code with two buttons, one to add a page and one to delete it.  It seems short enough to post here.

Erickc

unit pageexample;

interface

uses WebCore, WebUI, WebForms, WebCtrls, WebBtns, WebPages, WebCtnrs;

type

  TForm1 = class(TForm)
     Button1: TButton;
     PagePanel1: TPagePanel;
     Button2: TButton;
     procedure Button1Click(Sender: TObject);
     procedure Button2Click(Sender: TObject);
  private
     { Private declarations }
   page : TPage;
  public
     { Public declarations }
  end;

var
  Form1: TForm1;

implementation

procedure TForm1.Button1Click(Sender: TObject);
var
   button : TButton;
begin
  if not assigned( page ) then begin
     page := pagepanel1.NewPage;
     page.tab.caption := 'Something';

     button := TButton.Create( page );
     button.Top := 30;
     button.Left := 30;
  end;


end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 if assigned (page ) then begin
      page.Free;
      page := Nil;
 end;
end;
EWB Programming Books and Nice Component Library
See my EWB BLOG posts, at:
http://www.erickengelke.com
Sun, Oct 6 2024 11:57 AMPermanent Link

Artur2024

Avatar

Thank you very much for your help, I couldn't handle it.


I see that without this fragment:

     button := TButton.Create( page );
     button.Top := 30;
     button.Left := 30;

everything works too. Does it matter?
Sun, Oct 6 2024 9:06 PMPermanent Link

erickengelke

Avatar

Artur2024 wrote:

I see that without this fragment:
{
     button := TButton.Create( page );
     button.Top := 30;
     button.Left := 30;
}
everything works too. Does it matter?

It was just showing how to create something on a page.  Just filler.  It's not needed.
Erick
EWB Programming Books and Nice Component Library
See my EWB BLOG posts, at:
http://www.erickengelke.com
Image