Recent

Author Topic: TsWorkbookTabControl not working in laz 1.8.0  (Read 1280 times)

fmolina

  • New member
  • *
  • Posts: 11
TsWorkbookTabControl not working in laz 1.8.0
« on: December 28, 2017, 06:43:02 pm »
Hi,

Lazarus 1.8.0 + FPC 3.0.4, fpspreadsheet 1.8.2 (latest found by OPM). Tested with win32, win64 and linux x64 installations:
1. Start new project.
2. Drop a TsWorkbookSource on Form1
3. Drop a TsWorkbookTabControl and link to the TsWorkbookSource
4. Click in "Tabs" to open the string editor and define two tabs (Data and Results in my case). Close the editor and should see the two tabs correctly labeled.
5. Drop a TsWorksheetGrid and link to the TsWorkbookSource. Optionally, Client align and set goEditing (not necessary).
6. Compile and run. A single sheet named "Sheet1" is found (see attached image).

Further, on 64 bits IDE (both windows and linux) if I click on the second tab and then single click a few times (2-3) on the worksheet/tab body I get an AV.

Everything has default options (except as stated above). Am I doing something wrong? If not, is there a correction/workaround?

Regards

wp

  • Hero Member
  • *****
  • Posts: 5119
Re: TsWorkbookTabControl not working in laz 1.8.0
« Reply #1 on: December 28, 2017, 08:00:22 pm »
Oh - I see now that inheriting TsWorkbookTabControl from TTabControl instead of TCustomTabControl publishes too many properties - this will be changed when I have some time.

You must not use the Tabs to add pages. The TsWorkbookTabControl like all other fpspreadsheet controls is tightly connected to the workbook behind these controls. In order to add pages to the tabcontrol you must call the method AddWorksheet of the attached workbook (e.g. Workbooksource.Workbook). Notification between the controls then will automatically add a new page to the tabcontrol.

Have a look at the demo in examples/visual/fpsctrls_no_install:

Code: Pascal  [Select]
  1. procedure TForm1.SpeedButton1Click(Sender: TObject);
  2. var
  3.   sheetname: String;
  4.   i: Integer;
  5. begin
  6.   i := WorkbookSource.Workbook.GetWorksheetCount;
  7.   repeat
  8.     inc(i);
  9.     sheetName := Format('Sheet %d', [i]);
  10.   until (WorkbookSource.Workbook.GetWorksheetByName(sheetname) = nil);
  11.   WorkbookSource.Workbook.AddWorksheet(sheetName);
  12. end;
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

fmolina

  • New member
  • *
  • Posts: 11
Re: TsWorkbookTabControl not working in laz 1.8.0
« Reply #2 on: December 28, 2017, 08:54:48 pm »
OK, thanks. I understand, but I would have preferred to define all at design time.
By the way, where can I get a current version of the spready demo source? I kept navigating back and forth, found https://forum.lazarus.freepascal.org/index.php/topic,34515.msg226298.html#msg226298 but had no luck.

wp

  • Hero Member
  • *****
  • Posts: 5119
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10