TAdvStringGrid: GetCheckBoxState and FilterEdit

Windows 10 x64
TMS Component Pack 8.4.0.0
Delphi Berlin 10.1 update 1


Getting the checkbox state of unfiltered rows seems to work as expected. The problem is when a user applies filters: The user should be able to filter all rows and check all left after filtering by one click. Using some event handler I need to find all currently checked and visible rows and do something with those. Checking and unchecking all rows or only some of those individually works fine as well, I can even properly iterate only the visible/filtered rows. Only getting the checkbox state doesn't work properly, most or even all checked rows are returned to be unchecked.

The following code can be used to demonstrate the problem, simply input some number in the filter edit of the first column, without changing conditions or else. Add some breakpoints in the event handler, especially the lines with "insert" and "size" are interesting, because one can see which row indexes are believed to be checked and which are not. Using "checkAll" in 0:0 or individually checking/unchecking rows doesn't change a thing.

When the filter is removed getting the checkbox state works even if the checkbox state is not changed anymore. So load the app, filter the first column, check all, recognize most of the rows to be unchecked, remove the filter, all rows are visible with their former checkbox state, recognize or checked rows are properly recognized now. Apply the filter again and not all rows are properly recognized anymore.

Is this reproducible for, can you fix it and maybe even provide some workaround until the next release? Thanks!



AdvStringGrid3->ColCount						=  5;
AdvStringGrid3->RowCount						= 10;
AdvStringGrid3->FixedCols						=  1;
AdvStringGrid3->FixedRows						=  1;
AdvStringGrid3->FilterEdit->Enabled				= true;
AdvStringGrid3->MouseActions->CheckAllCheck		= true;
AdvStringGrid3->AddCheckBoxColumn(0);
//AdvStringGrid3->MouseActions->HotmailRowSelect	= true;
AdvStringGrid3->Options							<< goEditing;
AdvStringGrid3->RandomFill(false);




void __fastcall TForm1::GetCheckedClick(TObject *Sender)
{
	TAdvStringGrid*		grid(this->AdvStringGrid3);
	size_t				checkBoxColIdx(0);
	std::set<size_t>	checkedRows;


	for (int rowIdx = grid->FixedRows; rowIdx < grid->RowCount; ++rowIdx)
	{
		bool checked = false;
		if (!grid->GetCheckBoxState(checkBoxColIdx, rowIdx, checked) ||
			!checked)
		{
			continue;
		}


		checkedRows.insert(rowIdx);
	}


	size_t checkedRowsCnt = checkedRows.size();
}

When you have a filtered grid, i.e. a grid with hidden rows, you need to use the real row index to query the checkbox state and not the display row index.
I.e. call 

grid->GetCHeckBoxState((checkBoxColIdx, grid->RealRowIndex(rowIdx), checked)   

Damn, I already expected something like that... Thanks. Would you mind adding some note to RealRowIndex or the chapter about "hidden columns and rows" in general in the docs for FilterEdit (and/or *CheckBoxState)? This was not clear to me, so I got on the wrong track when searching for the cause of my problem.

Yes, I added it on our todolist for when we revise the docs.