Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

Author Topic: BUG Cells unmerged when press delete key  (Read 2470 times)

Tavr

• Newbie
• Posts: 2
BUG Cells unmerged when press delete key
« on: June 03, 2021, 09:47:03 am »
When I press DELETE key in merged cells - cells unmerged.
In addition, another problem, when editing merged cells Editor shown only in first cell of merged cells (EditorLineMode=elmMultiLine)

Code: Pascal  [Select][+][-]
1. procedure TsWorksheet.EraseCell(ACell: PCell; AKeepFormat: Boolean = false);
2. var
3.   r, c: Cardinal;
4. begin
5.   if ACell <> nil then begin
6.     r := ACell^.Row;
7.     c := ACell^.Col;
8.
9.     // Unmerge range if the cell is the base of a merged block
10.     if IsMergeBase(ACell) then
11.       UnmergeCells(r, c);
12.
« Last Edit: June 03, 2021, 11:17:55 am by Tavr »

wp

• Hero Member
• Posts: 9161
Re: BUG Cells unmerged when press delete key
« Reply #1 on: June 03, 2021, 12:05:46 pm »
When I press DELETE key in merged cells - cells unmerged.
I modified the EraseCell method so that the KeepFormat parameter is respected also for merged cells.
Code: Pascal  [Select][+][-]
1. procedure TsWorksheet.EraseCell(ACell: PCell; AKeepFormat: Boolean = false);
2. ...
3.     // Unmerge range if the cell is the base of a merged block
4.     if IsMergeBase(ACell) and not AKeepFormat then
5.       UnmergeCells(r, c);
6. ...

In addition, another problem, when editing merged cells Editor shown only in first cell of merged cells (EditorLineMode=elmMultiLine)
This is by design. I always was confused by Excel treating all cells of a merged block equally although only the left/upper cell can be modified and carries the format of the block.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...