Recent

Author Topic: TsWorksheetGrid: FrozenRows border disappears.  (Read 6997 times)

deepla

  • New Member
  • *
  • Posts: 10
TsWorksheetGrid: FrozenRows border disappears.
« on: July 11, 2021, 12:44:01 am »
Hello,
When I change the cell border using the CellBorder and CellBorderStyle functions of the TsWorksheetGridb component, the changed cell border is overwritten on the FrozenRows border, as shown in the figure below.
Is there a way to prevent the CellBorder from being overwritten on the FrozenRows border?

This has been confirmed on both Windows and Linux. A sample program is attached.
Best regards.

Lazarus 2.0.12 / fpc 3.2.0 / Windows 10 / Lubuntu 18.04(64bit)
FPSpreadsheet 1.13(r-8058)
« Last Edit: July 12, 2021, 07:14:31 am by deepla »

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TsWorksheetGrid: FrozenRows border disappears.
« Reply #1 on: July 11, 2021, 10:36:38 am »
Please test the new revision. Or, if you don't use trunk, change the procedure TsCustomWorksheetGrid.DrawCellBorders in unit fpspreadsheetgrid in the following way:

* Find the comment "Left border". In the following line add " and (ACol <> FixedCols)":
Code: Pascal  [Select][+][-]
  1.     // Left border
  2.     if GetBorderStyle(ACol, ARow, -1, 0, ACell, bs) and (ACol <> FixedCols) then

* Find the comment "Right border". In the following line add " and (ACol + 1 <> FixedCols)":
Code: Pascal  [Select][+][-]
  1.     // Right border
  2.     if GetBorderStyle(ACol, ARow, +1, 0, ACell, bs) and (ACol + 1 <> FixedCols) then

deepla

  • New Member
  • *
  • Posts: 10
Re: TsWorksheetGrid: FrozenRows border disappears.
« Reply #2 on: July 11, 2021, 12:02:56 pm »
Please test the new revision. Or, if you don't use trunk, change the procedure TsCustomWorksheetGrid.DrawCellBorders in unit fpspreadsheetgrid in the following way:

* Find the comment "Left border". In the following line add " and (ACol <> FixedCols)":
Code: Pascal  [Select][+][-]
  1.     // Left border
  2.     if GetBorderStyle(ACol, ARow, -1, 0, ACell, bs) and (ACol <> FixedCols) then

* Find the comment "Right border". In the following line add " and (ACol + 1 <> FixedCols)":
Code: Pascal  [Select][+][-]
  1.     // Right border
  2.     if GetBorderStyle(ACol, ARow, +1, 0, ACell, bs) and (ACol + 1 <> FixedCols) then
Thank you for your fixing.
However, if you scroll the sheet to the right, the same thing happens when the borders of the second and subsequent cells overlap the borders of FrozenCols.
To make this happen, add the following.
Code: Pascal  [Select][+][-]
  1. sWorksheetGrid1.Options := sWorksheetGrid1.Options
  2.                             - [goSmoothScroll]
  3.                             + [goThumbTracking];
  4. sWorksheetGrid1.DefaultColWidth := 30;
Best regards.

Lazarus 2.0.12 / fpc 3.2.0 / Windows 10 / Lubuntu 18.04(64bit) / FPSpreadsheet 1.13(r-8059)

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TsWorksheetGrid: FrozenRows border disappears.
« Reply #3 on: July 11, 2021, 04:33:39 pm »
Another attempt in the new revision... (if you don't use svn replace the "FixedCols" of the previous patch by "LeftCol").

BTW, quite some time after I wrote this, I feel that setting borders of neighboring cells is still very confusing. What do you think? Suppose one cell, say (r=6, c=6) with a border at the right, and the left neighboring cell (r=6, c=7) gets a border at the right as well, aren't you expecting the left neighboring cell to have both a left and right border? In the worksheet this is true, but in the worksheetgrid, the left border of (r=6, c=7) is removed.

deepla

  • New Member
  • *
  • Posts: 10
Re: TsWorksheetGrid: FrozenRows border disappears.
« Reply #4 on: July 11, 2021, 08:46:53 pm »
Another attempt in the new revision... (if you don't use svn replace the "FixedCols" of the previous patch by "LeftCol").

BTW, quite some time after I wrote this, I feel that setting borders of neighboring cells is still very confusing. What do you think? Suppose one cell, say (r=6, c=6) with a border at the right, and the left neighboring cell (r=6, c=7) gets a border at the right as well, aren't you expecting the left neighboring cell to have both a left and right border? In the worksheet this is true, but in the worksheetgrid, the left border of (r=6, c=7) is removed.
I had the same feeling during programming using the border by grid methods. Looking at this sample program, I think that the border by the worksheet method is easier to use than the border by the grid method.
Immediately, when CellBorder and FrozenBorder overlap, FrozenBorder disappears, but I solved it with the following settings.
Code: Pascal  [Select][+][-]
  1. sWorksheetGrid1.FrozenBorderPen.Width: = 2;
If the Frozen Border line width is larger than the Cell Border line width, the Frozen Border line will not disappear completely.
Thank you for fixing this component.

Lazarus 2.0.12 / fpc 3.2.0 / Windows 10 / Lubuntu 18.04(64bit) / FPSpreadsheet 1.13(r-8060)

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: [SOLVED] TsWorksheetGrid: FrozenRows border disappears.
« Reply #5 on: July 11, 2021, 09:34:26 pm »
I removed two calls to FixNeighborCellBorders which copy the state of the border flag of one cell to the corresponding edge of the neighbor cell, and this makes settings the cell borders in the grid more logical to me. But it is a two-sided knife...

The problem may be now with deleting. Suppose there is a border between cells B2 and C2 - this is displayed in a grid as a single line between these two cells. But there are three possibilities how this border may have been set: as cbEast to B2, as cbWest to C2 or as both. When it has been set as cbEast to B2 and I try to remove it from C2 I will not see any change; likewise when the border belongs to both cells and I remove it only from one. So quite frustrating...
« Last Edit: July 11, 2021, 11:18:02 pm by wp »

deepla

  • New Member
  • *
  • Posts: 10
Re: [SOLVED] TsWorksheetGrid: FrozenRows border disappears.
« Reply #6 on: July 12, 2021, 01:30:13 am »
I tried to check the operation with the updated component (r-8061). The duplicate issue between CellBorder and FrozenBorder has been resolved.
However, another problem occurred. The problem is that one cell can only have one directional border. If you draw the west and north borders in the same cell, the first direction border disappears.
Best regards.

Lazarus 2.0.12 / fpc 3.2.0 / Windows 10 / Lubuntu 18.04(64bit) / FPSpreadsheet 1.13(r-8061)

 

TinyPortal © 2005-2018