Subject RE: [IBO] How to mark a subset of records as selected?
Author Jason Wharton
Adrian,

> I have a query, displayed in a grid.
> I want to mark 'Select' certains rows, based on selection criteria.
> Ie mark all rows with value = 'aa' as selected.
> SelectAll, and deselect all, and select rows between a range
> are possible.
> But how do I achieve above?

Setup a scan of all the records in the buffer and set the Selected state of
each record individually.

You can do this as follows:

var
MyBufFld: TIB_Column;
begin
with MyQuery do
begin
Active := true;
FetchAll;
MyBufFld := BufferFieldByName( 'MYCOL' );
BufferFirst;
while ( not BufferEof ) do
begin
Selected[ BufferRowNum ] := ( MyBufFld.AsString = 'aa' );
BufferNext;
end
end
end

The only disadvantage I can think of is you will get a separate notification
for each record that has its selected status changed rather than getting a
single notification that a general dataset-wide multi-select operation
occurred.

HTH,
Jason Wharton