StringGrid Sizing lazarus / 31-LCL ---------------------------------------------------------------------- Weitentaaal · 2021-03-11 08:54 Hello Guys So i have problem, because i wanted to let my String Grid autosize itself so those "White Fields" (Shown in Picture) are gone. but the Grid Shouldnt get bigger as set in Design time. Somehting like if bigger then at design time set width and height then use those else auto size width and height of my grid. is this Possible ? ---------------------------------------------------------------------- wp · 2021-03-11 09:28 Add ColumnsFor each column which should keep the designed width, set "SizePriority" to 0For the column which should adjust its width to fill the empty space, keep "SizePriority" at 1. There can be also several columns with SizePriority 1; they will have the same width which is adjusted so that the empty space is filled. But note having more than one SizePriority columns can result in very annoying behaviour when the user is allowed to resize column widhts.Set the grid's "AutoFillColumns" to trueIt looks as if the exact value of the non-zero SizePriority is not important, it only matters whether it is zero or not. This is confirmed by a comment in the source code: Quote    // if SizePriority=0, column size should be unmodified     // if SizePriority<>0 means variable size column, its size     // is the average avalilable size. ---------------------------------------------------------------------- Weitentaaal · 2021-03-11 09:55 Sounds good thanks wp but i use the Method AutoSizeColumns, wich works fine, but iwanted to change the whole Grid width and not just the columns with. And i think your solution wouldn cover the height problem or am i wrong ? The Grid should get smaller if there isnt enough data to fill up the whole Grid. (GridWidth and GridHeight should change, but i don't know if u can do that at runtime) Thanks ---------------------------------------------------------------------- wp · 2021-03-11 10:07 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 procedure TForm1.FormShow(Sender: TObject);var  R: TRect;begin  R := StringGrid1.CellRect(StringGrid1.ColCount-1, StringGrid1.RowCount-1);  StringGrid1.ClientWidth := R.Right;  StringGrid1.ClientHeight := R.Bottom;end; On windows, this leaves about a 1-pixel space between the last cell and the grid border which looks wrong to me, but subtracting only 1 pixel (i.e, using R.Right-1 and R.Bottom-1 instead of R.Right and R.Bottom) inevitably displays the scrollbars. You may want to turn off grid lines (goHorizLine and goVertline) or the grid border to make this less prominent.