[SOLVED] TDBGrid cell widths lazarus / 16-Databases ---------------------------------------------------------------------- guest48180 · 2019-08-11 14:55 I use several DBGrids in this one program. Every user will undoubtedly want to grab the cell headers with the mouse and slide them around to adjust the cell widths to what they prefer. Is there a way to capture these widths and write them to a db so they they get loaded each time? Also: and this may be a bug. Dunno. But i have a field in my sqlite3 db of type CHAR. When i launch my program, TDBGrid gives me a default width of about 2000. I changed that to VARCHAR(1) to fix it. ---------------------------------------------------------------------- wp · 2019-08-11 17:22 You need persistent columns for the dbgrid. Either create persistent fields at designtime, or create columns after the dataset has been loaded. Then you have a property DBGrid1.Columns[index].Width which you can store in an ini or xml config file. The reason why some columns are ultra-wide is in the field definition. When you declare a string field without size restriction the grid prepares for a very long string. Again, when you create columns at designtime or at runtime after loading the db you can immediately apply a more meaningful value. See attached demo. ---------------------------------------------------------------------- guest48180 · 2019-08-11 18:35 That's clean, wp. Extremely helpful information. Thanks for passing it on. ---------------------------------------------------------------------- madref · 2019-08-24 16:58 Just an addition: You can also do this: 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 type  TMyDBGridHelper = class Helper for TDBGrid  public    function _ColumnByName(sFieldname: string): TColumn;  end;  // TMyDBGridHelper and then then this is possible: 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   DBGrid_Observaties_Zwakte._ColumnByName('Competence').Width := 430;