Solved

adding pages (tabsheets) to tpagecontrol

Posted on 2002-06-19
4
375 Views
Last Modified: 2010-04-04
hi everyone,

i run into a problem that seems trivial but i can't find a solution, i need to add on run time tabsheets to a tpagecontrol component, now that's easy. the problem is that per new tabsheet i need to add a new trichedit.

for example, i add a new tabsheet called NewTab that will contain an empty (and aligned to allclient) trichedit.

any way to do this?

thanks for any help

uri
0
Comment
Question by:urif
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 7092205
var
  t : TTabSheet;
  r : TRichedit;
begin
  t := TTabsheet.Create(self);
  t.PageControl := PageControl1;
  t.parent := PageControl1;
  r := trichedit.create;
  r.parent := t;
  r.align := alClient;
  t.show;
end;

just from head, not tested

meikl ;-)

0
 

Expert Comment

by:penich
ID: 7092209
Try to add a panel on each new tabsheet and use this panel like an layout for all your controls you need to add to your new tabsheet

NewTabSheet
    -----------
      NewPanel (Client Alignment)
         ----------
            Controls on the panel
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7092221
found an older sample from mine
(using a tmemo instead of an trichedit,
but this could be simpel replaced)

unit tn_u;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 StdCtrls, ComCtrls;

type
 TForm1 = class(TForm)
   Button1: TButton;  //Creates Pages
   PageControl1: TPageControl;
   CheckBox1: TCheckBox;  // Toggle Wordwrap
   Button2: TButton;  //Insert Lines
   procedure Button1Click(Sender: TObject);
   procedure CheckBox1Click(Sender: TObject);
   procedure PageControl1Change(Sender: TObject);
   procedure Button2Click(Sender: TObject);
 private
   { Private-Deklarationen }
 public
   { Public-Deklarationen }
 end;

var
 Form1: TForm1;

implementation

{$R *.DFM}

Var ActiveMemo : TMemo = nil;  //Holds the selected Memo

procedure TForm1.Button1Click(Sender: TObject);  //Creates New Page
var
 TS : TTabsheet;
 TM : TMemo;
begin
 TS := TTabsheet.Create(PageControl1);
 TS.Parent := PageControl1;
 TS.PageControl := PageControl1;
 TM := TMemo.Create(TS);
 TM.Parent := TS;
 TM.Align := alClient;
 ActiveMemo := TM;
 CheckBox1.checked := TM.WordWrap;
 PageControl1.ActivePage := TS;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);  //Toggle WordWrap On Off
begin
 If ActiveMemo <> Nil then
   ActiveMemo.WordWrap := CheckBox1.Checked;
end;

procedure TForm1.PageControl1Change(Sender: TObject);  //Get the new ActiveMemo
var i : Integer;
begin
 if PageControl1.PageCount > 0 then
   for i := 0 to PageControl1.ActivePage.ControlCount - 1 do
     if (PageControl1.ActivePage.Controls[i] is TMemo) then
     begin
       ActiveMemo := TMemo(PageControl1.ActivePage.Controls[i]);
       CheckBox1.Checked := ActiveMemo.WordWrap;
     end;
end;

procedure TForm1.Button2Click(Sender: TObject);  // Add Lines to ActiveMemo
begin
 If ActiveMemo <> Nil then
   ActiveMemo.Lines.Add('This Line will be added');
end;

end.

hope this helps

meikl ;-)
0
 

Author Comment

by:urif
ID: 7092224
and it works perfect, thx!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now