Recent

Author Topic: OnColumnMoved result unexpected  (Read 111 times)

fmc

  • New Member
  • *
  • Posts: 36
OnColumnMoved result unexpected
« on: November 14, 2019, 06:04:59 am »
In testing the integer values of a column moved (FromIndex / ToIndex), I was surprised to see the ever-hidden ID column started at Index 1 instead of Index 0.  The Table for the Grid (I tested this on both the TDBGrid and the TRxDBGrid) is like this:

Code: Pascal  [Select]
  1. 'CREATE TABLE IF NOT EXISTS customers(' +
  2.     'cust_id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
  3.     'cust_fname VARCHAR(20), ' +
  4.     'cust_lname VARCHAR(20), ' +
  5.     'cust_company VARCHAR(30), ' + ...

When I moved the fname column @index 1 one slot to the right, I thought it'd be in index 2 position.  But, it wasn't.  It was @index 3

Code: Pascal  [Select]
  1. procedure TForm_Main.DBGrid_AddCustomersColumnMoved(Sender: TObject; FromIndex,
  2.   ToIndex: Integer);
  3. var
  4.   x,y : Integer;
  5. begin
  6.   x := FromIndex;
  7.   y := ToIndex;
  8.   ShowMessage('Column moved from ' + IntToStr(x) + ' to ' + IntToStr(y));
  9. end;

The result is shown in the pic below.  I just thought it was interesting how these two Grids' Column Titles start @index 1 instead of index 0.  On face value, it affects nothing I can see.  Or am I missing something here?
Win X Pro / Lazarus 2.0.6 / FPC 3.0.4