[Lazarus] Inserting new pages into a TPageControl
Howard Page-Clark
hdpc at talktalk.net
Sun Oct 13 17:59:40 CEST 2013
On 11/10/2013 22:00, Mark Morgan Lloyd wrote:
> Given a TPageControl with several existing pages, how does one insert
> a page at a specified position rather than at the end?
This function should do it:
uses ComCtrls;
function InsertAt(ExistingIndex: integer;
aPageControl: TPageControl): TTabSheet;
begin
Result:=nil;
if (ExistingIndex<0) or (ExistingIndex>aPageControl.PageCount-1) then
Exit;
Result:= aPageControl.AddTabSheet;
if aPageControl.IndexOf(Result) <> ExistingIndex then
TNBPages(TCustomTabControl(aPageControl).Pages).Move(
aPageControl.IndexOf(Result), ExistingIndex);
end;
More information about the Lazarus
mailing list