Recent

Author Topic: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line  (Read 591 times)

dgrhoads

  • New Member
  • *
  • Posts: 42
The issue is that if in Excel, I establish a "Freeze Pane" line (View, Freeze Pane). When I try to select a cell using the fpsSpreadsheet package, I can select cells below the Freeze Pane line, but not above it. 

I am using the most recent fpsSpreadsheet package that I see is available  (fpspreadsheet-1.16.zip).  I am running Windows 10 with Lazarus 3.8.

I have attached a test system which illustrates this issue.

I await your enlightening comments and/or suggestions.

paweld

  • Hero Member
  • *****
  • Posts: 1356
Re: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line
« Reply #1 on: March 22, 2025, 07:19:27 am »
This is the design assumption - frozen cells are treated as a grid header. Below is part of the commentary from the source file FpSpreadSheetGrid
Code: Pascal  [Select][+][-]
  1. {
  2.   Internally, "frozen" cells are "fixed" cells of the grid. Therefore, it is
  3.   not possible to select any cell within the frozen panes - in contrast to the
  4.   standard spreadsheet applications.  
  5. }
Best regards / Pozdrawiam
paweld

jamie

  • Hero Member
  • *****
  • Posts: 6874
Re: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line
« Reply #2 on: March 22, 2025, 02:05:56 pm »
Assuming this is built from a string grid, you should be able to hook into the lower order class of the onclick operation and determine the cell.

A local class redefine should allow this
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 12761
Re: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line
« Reply #3 on: March 22, 2025, 02:38:30 pm »
paweld's description is correct. TsWorksheetGrid descends from the LCL grids TCustomGrid/TCustomDrawGrid, and uses the fixed cells to define the "frozen" cells. Since you cannot edit "fixed" cells of TCustomGrid, you cannot edit "frozen" cells of the worksheet grid.

Probably it is possible to overcome this limiation, but this is not on my priority list currently.

dgrhoads

  • New Member
  • *
  • Posts: 42
Re: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line
« Reply #4 on: March 22, 2025, 03:59:01 pm »
Thank you for your replies.  It is good to know that this is part of the design whether we agree with it or not.

On the other hand, it would be nice (always terrible words) if the Lazarus spreadsheet grid behaved in the same way as the actual spreadsheets did.  I do understand that there are many other priorities that take precedence (and rightly so).

Keep up the good work.

jamie

  • Hero Member
  • *****
  • Posts: 6874
Re: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line
« Reply #5 on: March 23, 2025, 01:19:26 am »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.sWorksheetGrid1MouseDown(Sender: TObject;
  2.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  3. Var
  4.   M:TPoint;
  5. begin
  6.   M := sWorkSheetGrid1.MouseToCell(Point(X,Y));
  7.   Caption := M.X.ToString+','+M.Y.Tostring;
  8. end;                                                
  9.  

This displays the cells you are clicking on.

of course if you are using this event for something else, you may need to actually test the cell counts to ensure one of them are 0 so you know you are in the headers.
Code: Pascal  [Select][+][-]
  1.  InHeaderFlag :=  (M.X = 0 or M.Y = 0);
  2.  
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6874
Re: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line
« Reply #6 on: March 23, 2025, 01:27:18 am »
you may like this one better.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.sWorksheetGrid1HeaderClick(Sender: TObject; IsColumn: Boolean;
  2.   Index: Integer);
  3. Var
  4.   M:TPoint;
  5.   C:TPoint;
  6. begin
  7.   M := Mouse.CursorPos;
  8.   M := sWorkSheetGrid1.ScreenToClient(M);
  9.  C := sWorkSheetGrid1.MouseToCell(M);
  10.   Caption := C.X.ToString+','+C.Y.Tostring;
  11. end;                                                      
  12.  
  13.  
That uses the existing header OnClick.
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6874
Re: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line
« Reply #7 on: March 23, 2025, 02:01:29 am »
Also another comment on this..

 If you are trying to obtain the actual TEXT content of the header then don't bother.

all of those have been overridden however, if all you need is the actual INDEXes then use the code I presented and change them into chars if needed.

 If you are trying to obtain actual text that may not be the default, then you need to keep an external String List of the items and use the Index to reference them. Using the OnGetCOL or ROW events you can populate the headers since they change each time you make a cell click.

The only true wisdom is knowing you know nothing

dgrhoads

  • New Member
  • *
  • Posts: 42
Re: fpsSpreadsheet. Unable to select cells above the "Pane Freeze" line
« Reply #8 on: March 23, 2025, 03:11:52 am »
Thanks.  I have got it working.

I wanted two things:  the cell coordinates and the contents of the cell.

It turns out that the cell coordinates are different in the header than in the rest of the grid.  The header coordinates are 1 based while the others are 0 based.  But that is easy to manage. 

I appreciate the lesson(s) you provided me in your code.  Very helpful.

Again, many thanks,
David

 

TinyPortal © 2005-2018