TMSFNCDataGrid Index + RealIndex

I am very confused now. We updated TMSFNCDataGrid and Index + RealIndex is now used completely different:

// Column 1 (Index 0)
this->DataGrid->Strings[0][0] = L"Spalte 1";
// Column 2 (Index 1)
this->DataGrid->Strings[1][0] = L"Spalte 2";
// Column 3 (Index 2)
this->DataGrid->Strings[2][0] = L"Spalte 3";
// Column 4 (Index 3)
this->DataGrid->Strings[3][0] = L"Spalte 4";

Before the Update the following Code:

	ShowMessage(L"Index: " + IntToStr(this->DataGrid->ColumnByName(L"Spalte 3")->Index));
	ShowMessage(L"Index Real: " + IntToStr(this->DataGrid->Root->RealToDisplayColumn(this->DataGrid->ColumnByName(L"Spalte 3")->Index)));
	this->DataGrid->MoveColumn(2, 0);
	ShowMessage(L"Index: " + IntToStr(this->DataGrid->ColumnByName(L"Spalte 3")->Index));
	ShowMessage(L"Index Real: " + IntToStr(this->DataGrid->Root->RealToDisplayColumn(this->DataGrid->ColumnByName(L"Spalte 3")->Index)));

Displayed:

Index: 2
Index Real: 2
Index: 2
Index Real: 0

Now the same Code produces the following output:

Index: 2
Index Real: 2
Index: 0
Index Real: 1

So if i understand it correctly:
Index is now holding the "real" Index where the column is moved to.
Real Index is now holding 1 based Index where the column is moved to?

Is this documented somewhere? Or is there somewhere a site a document where such changes are published? As i can't read this out of the "normal version history" which are only key points from the releases?!

For the moment this is breaking our application which is not optimal :see_no_evil_monkey:

Thank you.

Hi,

The original code had a bug, MoveColumn did not move the column inside the columns collection. You can see this because Index still remains 2 even after the Move. Now, MoveColumn will move the collection item properly. The Index that you are using is the index of the column object inside the collection, and because MoveColumn has moved the collection item, the Index automatically reflects the position in the grid visually. Originally, the Index didn't change, and the RealToDisplayColumn(2) gave 0. After the change, you actually now call RealToDisplayColumn(0), which gives 1, since the column with index 0 originally ("Spalte 1") has moved one to the right. What you actually want to do is make sure you always start with the original index before the move:

var
  idx: Integer;
begin
  idx := DataGrid.ColumnByName('Spalte 3').Index;

  TTMSFNCUtils.Log('Index: ' + IntToStr(idx));
  TTMSFNCUtils.Log('Index Real: ' + IntToStr(DataGrid.Root.RealToDisplayColumn(idx)));

  DataGrid.MoveColumn(2, 0);

  TTMSFNCUtils.Log('Index: ' + IntToStr(idx));
  TTMSFNCUtils.Log('Index Real: ' + IntToStr(DataGrid.Root.RealToDisplayColumn(idx)));
end;

Which gives

Debug Output: Index: 2 Process Project16.exe (9660)
Debug Output: Index Real: 2 Process Project16.exe (9660)
Debug Output: Index: 2 Process Project16.exe (9660)
Debug Output: Index Real: 0 Process Project16.exe (9660)

Thanks for clarification.

Are such changes documented anywhere? Would be good for future updates of our applications when we can take a look if there are such "breaking" changes ;-)

The version history mentions:

Improved : support for moving columns at column collection

Although the unwanted side-effect is indeed that when the index is used in a RealToDisplayColumn scenario it is in fact a "breaking change", yet the original intention was not to use collection indexes in combination with display/real column indexes.