PageControlChanging (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This project requires a TPageControl, several TTabSheets (to add sheets, right-click the Page Control and select New Page from the context menu), and a TEdit control on the first tab sheet. You are not allowed to change to a new page if the active page is TabSheet1 and there is no text in the Edit Control.

Code

procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean);
begin
  if ((Sender as TPageControl).ActivePage = TabSheet1) then
    AllowChange := (Edit1.Text <> '')
  else
    AllowChange := True;
end;

Uses