RAD Studio VCL Reference
|
Occurs immediately before a new tab is selected.
property OnChanging: TTabChangingEvent;
__property TTabChangingEvent OnChanging;
Write an OnChanging event handler to take specific action immediately before the selected tab changes. Set the AllowChange parameter to false to prevent the change.
Use an OnChanging event handler to prevent the user from leaving a tab setting until certain conditions have been met. An OnChanging event handler can also be used to save information about the current state of the tab control before it is changed by a new tab selection.
C++ Examples:
/* 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. The user is not allowed to change to a new page if the active page is "TabSheet1" and there is no text in the Edit Control. */ void __fastcall TForm1::PageControl1Changing(TObject *Sender, bool &AllowChange) { if ((dynamic_cast<TPageControl *>(Sender))->ActivePage == TabSheet1) AllowChange = (!Edit1->Text.IsEmpty()); else AllowChange = true; if (AllowChange == false) { MessageBeep(0); Edit1->SetFocus(); } }
Delphi Examples:
{ 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. The user is not allowed to change to a new page if the active page is "TabSheet1" and there is no text in the Edit Control. } procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean); begin if ((Sender as TPageControl).ActivePage = TabSheet1) then AllowChange := (Edit1.Text <> '') else AllowChange := True; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|