Solved

adding pages (tabsheets) to tpagecontrol

Posted on 2002-06-19
4
378 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi: how to send PJL commands to printer 3 108
Delphi inherited method 6 76
DBGrid or StringGrid ? 6 103
Delphi problems to abort a printjob 9 24
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 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