Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

adding pages (tabsheets) to tpagecontrol

Posted on 2002-06-19
4
Medium Priority
?
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

609 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