Delphi - How to add tabs in TMEMO?

3k views Asked by At

As shown like here.

pic: tabs with memo

Currently, my TMEMO displays bunch of different data, like this:

Data #1 Paragraphs

Data #2 Paragraphs

Data #N Paragraphs

So to avoid scrolling, I want to add tabs to the Nth number.

So what components do I need and how should I intiate the process?

3

There are 3 answers

0
Z . On

you need to use a combination of a TMemo and TTabControl.

2
Agustin Seifert On

Do not know how you get your paragraphs but you'll have to iterate through them, creating a TabSheet and a Memo for each.

procedure TfrmMemo.CreateTabsWithMemo;
var
  pgControl: TPageControl;
  TabSheet: TTabSheet;
  Memo: TMemo;
begin
  pgControl := TPageControl.Create(self);
  pgControl.Parent := Self;
  pgControl.Align := alClient;

  //Do this for each paragraph
  TabSheet := TTabSheet.Create(pgControl);
  TabSheet.PageControl := pgControl;
  TabSheet.Caption := Format('Tab %d', [pgControl.PageCount]);

  Memo := TMemo.Create(TabSheet);
  Memo.Parent := TabSheet;
  Memo.Align := alClient;

  Memo.Lines.Text := 'Your Paragraph here'
  ///
end;
0
Danny Rancher On

Use TPageControl and TTabSheet. Place a TMemo component on each TTabSheet.

You can drage the TPageControl onto the form to get started.