Set the DBGrid column width for a SQLite3 table lazarus / 16-Databases ---------------------------------------------------------------------- banffguy · 2016-10-04 22:19 Lazarus 1.6,FPC 3.0,sqlite3.8.3.1 Have table works fine in grid and other functions work OK Want to set the column widths for each colum, A statement; Form1.DBGrid1.columns[4].width := 112; has no effect on the column width.  Works fine using a Tdbf table but not for SQLite. Anyone have an answer or a solution? Or is the only to change the columne through the sqlite dot commands Thanks ---------------------------------------------------------------------- totya · 2016-10-05 00:51 Hi! It's working perfectly for me, with TSQLite3Dataset. ---------------------------------------------------------------------- LacaK · 2016-10-05 05:31 How do you define columns in your DBGrid1 ? At design time or at runtime ? I guess, that you have "empty" grid at design time and columns are created at runtime dynamicaly based on underlaying DataSource. Then you must set column Width after each opening of DataSource ... ---------------------------------------------------------------------- banffguy · 2016-10-06 04:43 Did the column settings in the Object Inspectorand it works fine, was trying to make changes by code but didn't seem to work.  Not a big problem thought it might be easier debugging and adjusting when laying out the grid. Thanks for your comments and help. Banffguy ---------------------------------------------------------------------- totya · 2016-10-06 04:48 LacaK wrote: QuoteThen you must set column Width after each opening of DataSource ... Plaese show your code, or create simple demo app of this problem, and attach here. ---------------------------------------------------------------------- vrull · 2016-11-08 22:43 The below procedure adjusts columns: 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 TfrmGrid.SmartColumnAdjust;var  i : integer;  intSize, colSize : integer;begin  intSize := ReadSetting('fixedColumnSize', 80); // this sets the minimal width of non-adjustable columns, 80 is the default width  for i := 0 to Pred(DBGrid.Columns.Count) do    if not (DBGrid.Columns[i].Field.DataType in [ftString, ftMemo, ftWideString, ftWideMemo, ftFmtMemo]) then // all columns with text data are auto- adjusted, so we skip them      begin // this is non-adjustable column        DBGrid.Columns[i].SizePriority := 0; // this prevents auto- adjust by internal routine        colSize := IntMax(intSize, DBGrid.Canvas.GetTextWidth(DBGrid.Columns[i].Title.Caption)); // max of column title width or default width        DBGrid.Columns[i].Width := colSize; // set the width      end;  DBGrid.AutoSizeColumns; // force setting auto-adjustable columnsend;