Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate run time TTabItem , firemonkey
    text
    copied!<p>Seems like i need some help with a project. I have a routine , that constructs run time multiple TabItems on to a page control in firemonkey, and i want to have a close button on the tab. The new tab has a checkbox for the close button loading from the styler of the tabitems. The page has a default tab, and within some button, i am adding run time the new tab items. I have managed to apply the event for closing the default tab page, but doesn't work within the run time created tab pages. Any help would be appreciated.</p> <p>This is the piece of code for the runtime tabitems</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); var t : TTabItem; o : TFmxObject; i : Integer; c : TControl; begin t := TTabItem.Create(pgeControl); t.Parent := pgeControl; o := FindBinding('imgCloseTabPage'); if o&lt;&gt;nil then begin for i := 0 to ComponentCount - 1 do begin if Components[i] is TCheckBox then begin TCheckBox(Components[i]).OnClick := CheckBox1Click; end; end; end; if pgeControl.TabCount - 1 &lt;= nTab then begin nTab := nTab + 1; t.Index := nTab end else begin t.Index := pgeControl.TabCount - 1; nTab := pgeControl.TabCount - 1; end; t.Tag := nTab; t.Text := 'Some text...' + ' ' + IntToStr(nTab); t.Name := 'tabPatient' + IntToStr(nTab); t.Height := 35; t.Width := 250; t.Margins.Top := 0; t.Margins.Left := 0; t.Margins.Bottom := 0; t.Margins.Right := 0; t.Padding.Top := -5; t.Padding.Left := 0; t.Padding.Bottom := 0; t.Padding.Right := 0; t.TextAlign := TTextAlign.taLeading; t.Width := (Length(t.Text) * 6 ) + 60; t.Font.Size := 15; t.StyleLookup := 'tabMainStyle1'; l := TLayout.Create(t); l.Parent := t; l.Align := TAlignLayout.alClient; l.Margins.Top := -5; l.Margins.Left := 5; l.Margins.Right := 5; l.Margins.Bottom := 5; l.Padding.Top := 0; l.Padding.Left := 0; l.Padding.Bottom := 0; l.Padding.Right := 0; pgeControl.ActiveTab := pgeControl.Tabs[pgeControl.TabCount - 1]; end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload