TMSFNCDataGrid Column Dragging and Positioning

ColumnDragging doesn´t seem to work when a DatabaseAdapter is connected. I have tried it in BiolifeClientDataSet-Demo. Basically the Column can be moved but as soon as you scroll the column jumps back to the original position.

I´ve found this issue because my actual problem is setting the column-position by code. I´ve tried doing it via the column in the DatabaseAdapter and the DatabaseAdapter.GridColumn:

for var lFieldName in lObj_LayoutDef do
begin
  lColumn := lDataGridAdapter.ColumnAtField[lFieldName];
  if lColumn <> nil then
  begin
    // lColumn.Index := I;
    lColumn.GridColumn.Index := I;
    Inc(I);
  end;
end;

Unfortunately both approaches didn´t work. Is this even supoorted?

Hi,

When connected to the DatabaseAdapter, it's the fields collection that determine the position when AutoCreateColumns is set to true. The grid columns itself are automatically arranged so that can be ignored. To manually position the columns when connected to a database adapter, set AutoCreateColumns to false, then use

var
  lColumn: TTMSFNCDataGridDatabaseAdapterColumn;
  I: Integer;
begin
  I := 0;
  for var lFieldName in ClientDataSet1.FieldDefList do
  begin
    lColumn := lDataGridAdapter.ColumnAtField[lFieldName];
    if lColumn <> nil then
    begin
      lColumn.Index := I;
      inc(I);
    end;
  end;

  lDataGridAdapter.Update;
end;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.