[Solved] Stop a grid adding columns and rows when I move right or down? lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- daveinhull · 2022-01-27 23:50 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     Case Key ofVK_Right, VK_Tab:  begin    showmessage (wsg3Year.col.ToString + '....' + wsg3Year.ColCount.ToString);      if wsg3Year.Col < wsg3Year.colCount then        wsg3Year.Col := wsg3Year.Col + 1;      Key := 0;  end;.........end; ---------------------------------------------------------------------- daveinhull · 2022-01-30 16:41 Hi, Any thoughts from anyone? Thanks Dave ---------------------------------------------------------------------- wp · 2022-01-30 17:19 Remove the option aeNavigation from the AutoExpand property of the grid (https://wiki.lazarus.freepascal.org/TsWorksheetGrid#New_grid_pro perties). ---------------------------------------------------------------------- daveinhull · 2022-01-31 08:46 Hi wp, Wow! Is there nothing you don't know  That's done it and I had done the same thing in loads of on event code! Really appreciate you help Thanks Dave