Solved

adding pages (tabsheets) to tpagecontrol

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

912 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

19 Experts available now in Live!

Get 1:1 Help Now