Show column number in dbgrid with SQlite lazarus / 16-Databases ---------------------------------------------------------------------- Ericktux · 2016-04-12 19:46 Hello everyone,  as I can show a numbered column and then load the data from SQLite database. ---------------------------------------------------------------------- mangakissa · 2016-04-13 06:46 You mean 1, 2, 3, 4, 5, ........ Or just the rowid? ---------------------------------------------------------------------- Ericktux · 2016-04-13 13:52 hi, i want have the first column of numering in Dbgrid: No       Name            years ------------------------------------ 1         Erick              32 2         Bernardo       18 3         Luis               22 4         Manuel          15 5         Juan              25 I'm using Lazarus 1.6 in Win10x64 ---------------------------------------------------------------------- balazsszekely · 2016-04-13 14:02 @Pascalito100 I would use a calculated field, but probably there are other methods too. ---------------------------------------------------------------------- Ericktux · 2016-04-13 14:19 hello Getmem excuse my English (google translate) how to use "calculated field" ---------------------------------------------------------------------- balazsszekely · 2016-04-13 14:48 1. See attachment 2. 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.qTestBeforeOpen(DataSet: TDataSet);begin  FRecNo := 0;end; procedure TForm1.qTestCalcFields(DataSet: TDataSet);begin  Inc(FRecNo);  DataSet.FieldByName('No').AsInteger := FRecNo;end; Please note you have to reset FRecNo when you insert, delete something. ---------------------------------------------------------------------- Ericktux · 2016-04-14 03:46 thank you very much, it works for me  in desingmode set SQLQuery1 Active=true, then double clic in DBGRID, next "Add fields" (fields are added) then "Add" for new column and rename a "No", next localize Column "No" as first column, next add this code to the event "OnDrawColumnCell" of DBGRID. 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 TForm2.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;  DataCol: Integer; Column: TColumn; State: TGridDrawState);var  vDbGrid: TDBGrid absolute Sender;begin  // only do the next line if this event generated for  // the first columnn (column with index 0)  if DataCol=0 then    vDbGrid.Canvas.TextOut(Rect.Left + 2                         , Rect.Top + 2                           , IntToStr(vDbGrid.DataSource.DataSet.RecNo));end;   if you get Error "Operation cannot be performed on an active dataset" then set SQLQuery1 active=false, or SQLite3Connection1 property “Connected=false” Greetings from Peru ---------------------------------------------------------------------- mangakissa · 2016-04-14 06:53 Why would you draw the first column if DBGrid is doing it for you?