I am using a pagecontrol component开发者_如何学编程 and I need to add a button and click it to go to a specified page.
How can I do this please?
Add a button to the form and write an OnClick event handler like this:
procedure TMyForm.Button1Click(Sender: TObject);
begin
  PageControl1.ActivePage := TabSheet1;
end;
You can use ActivePageIndex:
procedure TForm1.Button1Click(Sender: TObject);
begin
  PageControl1.ActivePageIndex := 0;
end;
Can I just add that you cannot set the active page within the OnChange event (I tried for ages!). Any checks that are needed must be done within the OnChanging event and then set the Allowchange var to true or false accordingly:
procedure Tfrm_AspireParams.PC_OptionsChanging(Sender: TObject;
  var AllowChange: Boolean);
begin
 AllowChange := true;
 if fActivated then
 begin
   if BBtn_Timesheets_Save.Enabled then  // They have not saved changes on this tab.
   begin
     messagedlg('Please save the page first', mtInformation, [mbOK], 0);
     AllowChange := False;
   end;
 end;
end;
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论