Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a tab-edit. 2

Status
Not open for further replies.

YamahaJojje

Programmer
May 27, 2004
11
SE
Hi!

I need help making a tab-edit like 1st page 2000 or simular. I cant get i to work i want to create tabs on runtime and that i have solved but how to use them then? RichEdit1.Seltext dosent work. I need the code to use dynamacily cretated Trichedit in a ttabsheet. I hope i was clear enough.

Mvh
Johan Friman
 
I'm afraid you're going to have to clarify your needs further. What exactly are you trying to do with the dynamically created TTabSheet and TRichEdit? Are you trying to make the TTabSheet the container for the TRichEdit?

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
No a TPageControl I am trying to do a text editor where you can open multiable files in one window.
 
I placed the following in a TMainMenu menu item click event and it seems to do what you want.
Code:
var
  NewTabSheet: TTabSheet;
  NewRichEdit: TRichEdit;
begin
  NewTabSheet := TTabSheet.Create(PageControl1);
  NewTabSheet.PageControl := PageControl1;
  NewRichEdit := TRichEdit.Create(NewTabSheet);
  NewRichEdit.Parent := NewTabSheet;
  NewRichEdit.Align := alClient;
end;

Hope this helps!

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Yes that works thanks! :) but how do i use the TRichEdit then? If i want to save the text. With one you use RichEdit1.Lines.Savetofile but what do i use here?
 
Hi YamahaJojje,

there are various possibilities, here's just one small and easy example :

Code:
procedure tform1.Save(filename : string);
var
  TabSheet: TTabSheet;
  RichEdit: TRichEdit;
  I: integer;
begin
  TabSheet:=PageControl1.ActivePage;
  if TabSheet.ControlCount > 0 then
   for I:=0 to TabSheet.ControlCount-1 do
    if TabSheet.Controls[I] is TRichEdit then
     begin
      RichEdit:=TRichEdit(TabSheet.Controls[I]);
      RichEdit.Lines.SaveToFile(FileName);
     end;
end;

HTH,
Daddy

--------------------------------------
What You See Is What You Get
 
Hi YamahaJojje,

small update :
Code:
procedure tform1.Save(filename : string);
var
  TabSheet: TTabSheet;
  RichEdit: TRichEdit;
  I: integer;
begin
  TabSheet:=PageControl1.ActivePage;
  if TabSheet.ControlCount > 0 then
   for I:=0 to TabSheet.ControlCount-1 do
    if TabSheet.Controls[I] is TRichEdit then
     begin
      RichEdit:=TRichEdit(TabSheet.Controls[I]);
      RichEdit.Lines.SaveToFile(FileName);
      [b]Break;[/b] //don't need to loop all controls
     end;
end;

HTH,
Daddy

--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top