Recent

Author Topic: [Solved] Stop a grid adding columns and rows when I move right or down?  (Read 1635 times)

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Hi,

I'm trying to limit my worksheet (grid) to 15 columns, so set the value ColCount to 15.
However, if I move the cell right it just adds more columns.
I've tried adding a keydown handler to check if its the right arrow key and if the current cell is less that ColCount then add one to col and zero the key, but this doesn't work, it still just adds columns. If I monitor the col value and the colCount values, the ColCount value increase when the col value is (at least) 2 less that the ColCound value.

Am I missing something here?

[Edit: I found that I should be using Get Last ColIndex rather than ColCount, but still I'm trapping the cursor move rather than limiting the grid size]

Thanks Dave

Code: Pascal  [Select][+][-]
  1.    
  2. Case Key of
  3. VK_Right, VK_Tab:
  4.   begin
  5.     showmessage (wsg3Year.col.ToString + '....' + wsg3Year.ColCount.ToString);
  6.       if wsg3Year.Col < wsg3Year.colCount then
  7.         wsg3Year.Col := wsg3Year.Col + 1;
  8.       Key := 0;
  9.   end;
  10. ...
  11. ...
  12. ...
  13. end;
  14.  
« Last Edit: February 02, 2022, 10:35:18 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

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: Stop a grid adding columns and rows when I move right or down?
« Reply #1 on: January 30, 2022, 05:41:38 pm »
Hi,

Any thoughts from anyone?

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: 9594
Re: Stop a grid adding columns and rows when I move right or down?
« Reply #2 on: January 30, 2022, 06:19:32 pm »
Remove the option aeNavigation from the AutoExpand property of the grid (https://wiki.lazarus.freepascal.org/TsWorksheetGrid#New_grid_properties).
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
[Solved] Re: Stop a grid adding columns and rows when I move right or down?
« Reply #3 on: January 31, 2022, 09:46:01 am »
Hi wp,

Wow! Is there nothing you don't know  :D
That's done it and I had done the same thing in loads of on event code!

Really appreciate you help

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