Recent

Author Topic: FPSpreadsheet cell merge/unmerge problem  (Read 2267 times)

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
FPSpreadsheet cell merge/unmerge problem
« on: October 07, 2017, 10:49:02 am »
HI

I'm just starting to experiment with FPSpreadsheet and have come across what looks like a bug, but it might just be my misunderstanding on how one of the functions work.
I have a button that merges the selected range of cells. I have another button that unmerges at the active cell.
If the active cell is not in the range of merged cells the merged cells still unmerge. Also if I merge two sets of cells, and the active cell is in neither and I press the unmerge button, it unmerges the last set of cells to be merged?

Any thoughts on this?

Many thanks
Dave
« Last Edit: October 07, 2017, 10:50:44 am by daveinhull »
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: FPSpreadsheet cell merge/unmerge problem
« Reply #1 on: October 07, 2017, 11:15:58 am »
I suppose you have a TsWorksheetGrid on the form. Make sure that there is also a TsWorkbookSource which is linked to the property WorkbookSource of the grid. Add a TActionList to the form, add a TsMergeAction to the actionlist and link its WorkbookSource as well. Link the action to the property Action of your MergeButton. Run the project, select the cell range to be merged, press the button and the cells will be merged. To unmerge, select the merged block and press the button again.

The basic tutorial for setting up a spreadsheet GUI is http://wiki.lazarus.freepascal.org/FPSpreadsheet_tutorial:_Writing_a_mini_spreadsheet_application.

If this does not help put your fpspreadsheet-related code into a simple project and post it here (only pas, lfm, lpi, lpr files and maybe

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: FPSpreadsheet cell merge/unmerge problem
« Reply #2 on: October 07, 2017, 03:18:58 pm »
Hi wp,

Thanks for the quick reply.
I've done most of what you suggested, but I can't find the TsMergeAction in the FPSpreadsheet tab list of controls.
I just created a normal button and added the following code:
Code: Pascal  [Select][+][-]
  1. procedure Tform1.Button1click(Sender: Tobject);
  2. begin
  3.    FPGrid.MergeCells (FPGrid.Selection.Left, FPGrid.Selection.Top, FPGrid.Selection.Right, FPGrid.Selection.Bottom)
  4. End;  

I'd already been through the tutorial you mentioned, but didn't see anything about merging, but found an example somewhere else.

Any thoughts on where I'm going wrong?

Thanks
Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: FPSpreadsheet cell merge/unmerge problem
« Reply #3 on: October 07, 2017, 03:27:08 pm »
Did you ever work with Actions?

Add a TActionList (palette "Standard", right-most icon). Double-click the ActionList. Click on the down-arrow next to "+", select "New standard action", scroll down to category "FPSpreadsheet", the Merge-Action is at the end of the list --> the action is added to the action list. Whenever the action is selected in the ActionList, you can modify its properties in the ObjectInspector. You must set its WorkbookSource to the workbooksource that you have on the form.

In order to use an action you select the component (here: your button) and click on its propery Action in the Object inspector. Select the MergeAction.

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: FPSpreadsheet cell merge/unmerge problem
« Reply #4 on: October 07, 2017, 03:40:01 pm »
Hi wp,

Excellent, completely missed that. Have only used ActionLists once before, so missed the small dropdown to the standard actions.

Appreciate your help and patience

Thanks
Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

 

TinyPortal © 2005-2018