Recent

Author Topic: TabIndex value doesn't change the grid on Lazarus 1.8.2 [Answered by wp]  (Read 2464 times)

totya

  • Hero Member
  • *****
  • Posts: 720
Hi!

This (ugly demo) code works on Lazarus 1.6.4, but not on Lazarus 1.8.2.

Thanks...

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   fpspreadsheetctrls, fpspreadsheetgrid,
  10.  
  11.   fpsallformats;
  12.  
  13. type
  14.  
  15.   { TForm1 }
  16.  
  17.   TForm1 = class(TForm)
  18.     Timer: TTimer;
  19.     WorkbookSource: TsWorkbookSource;
  20.     WorkbookTabControl: TsWorkbookTabControl;
  21.     procedure FormActivate(Sender: TObject);
  22.     procedure FormCreate(Sender: TObject);
  23.     procedure TimerTimer(Sender: TObject);
  24.   private
  25.     WorksheetGrid: TsWorksheetGrid;
  26.   public
  27.  
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. {$R *.lfm}
  36.  
  37. { TForm1 }
  38.  
  39. procedure TForm1.FormCreate(Sender: TObject);
  40. begin
  41.   Timer.Enabled:= false;
  42. end;
  43.  
  44. procedure TForm1.FormActivate(Sender: TObject);
  45. begin
  46.   WorkbookSource.FileName:= 'test_multi.xls';
  47.  
  48.   with WorkbookTabControl do
  49.     begin
  50.       Align:= alClient;
  51.       WorkbookSource:= Self.WorkbookSource;
  52.     end;
  53.  
  54.   WorksheetGrid:= TsWorksheetGrid.Create(self);
  55.  
  56.   if Assigned(WorksheetGrid) then
  57.       with WorksheetGrid do
  58.       begin
  59.         Parent:= WorkbookTabControl;
  60.         Align:= alClient;
  61.         WorkbookSource:= Self.WorkbookSource;
  62.  
  63.         Timer.Enabled:= true;
  64.       end;
  65. end;
  66.  
  67. procedure TForm1.TimerTimer(Sender: TObject);
  68. begin
  69.   Timer.Enabled:= false;
  70.  
  71.   if WorkbookTabControl.TabIndex < WorkbookTabControl.Tabs.Count -1
  72.     then WorkbookTabControl.TabIndex:= WorkbookTabControl.TabIndex +1
  73.     else WorkbookTabControl.TabIndex:= 0;
  74.  
  75.   Timer.Enabled:= true;
  76. end;
  77.  
  78. end.
  79.  
« Last Edit: April 22, 2018, 10:25:09 pm by totya »

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TabIndex value doesn't change the grid on Lazarus 1.8.2
« Reply #1 on: April 22, 2018, 10:14:59 pm »
For Delphi compatibility, this behavior of TCustomTabControl and its descendants was changed in Laz 1.8. Please see the 1.8 release notes: http://wiki.freepascal.org/Lazarus_1.8.0_release_notes#TCustomTabControl_setting_TabIndex_or_PageIndex_by_code. Here you find the information that you must add nboDoChangeOnSetIndex  to the TabControl's Options to get back the old behavior.

totya

  • Hero Member
  • *****
  • Posts: 720
Re: TabIndex value doesn't change the grid on Lazarus 1.8.2
« Reply #2 on: April 22, 2018, 10:24:42 pm »
Hi!

Thank you master! :)

Code: Pascal  [Select][+][-]
  1. Options:= Options+ [nboDoChangeOnSetIndex];

 

TinyPortal © 2005-2018