Subject | Re: [IBO] Is Cells[i,j] the fastest way to access all data in an IB_Grid -> IB_Query? |
---|---|
Author | Geoff Worboys |
Post date | 2003-01-16T23:47:14Z |
> In order to get all information in each cell of the IB_Grid I haveThere are many ways to get data. I would not recommend reading
> used Cell[i,j].
> This is in order to print the grid contents.
> Is this the fastest way or is there a way to get all the data from
> each field of each record on the IB_Query?
directly from the grid, since it will not have all cells available
until all rows are available in the associated dataset.
(Hopefully) obviously you can read from IB_Query using a First/Next
loop and reading from the current row. From the question I presume
that you dont want this - presumably to avoid moving the current
row selection. In which case...
Check out the various Buffer* properties and methods of TIB_Query.
These allow you to scan through a dataset with a row reference that
is independent of the currently selected row. Understand that this
means that related datasets (master/detail and lookup datasets)
will not be synchronised with the buffer row, since those
relationships use the actual current row and not the buffer row.
Also, beware when using the Buffer* properties that this same
feature is used by TIB_Grid (and various other features), so try
not to use this capability inside grid events that may occur
during scrolling etc - or inside dataset lookup/search events.
ie. Using the Buffer* properties and methods is effectively the
same code as you use for a first/next loop, but you replace
first/next etc with BufferFirst/BufferNext etc.
eg:
with IB_Query1 do
begin
BufferFirst;
while not BufferEof do
begin
// use BufferFields or BufferFieldByName etc
// to access the buffer column instances
BufferNext;
end;
end;
The same performance issues apply as with normal dataset loops.
On a large dataset you should avoid using BufferFieldByName, if
feasible, and use direct column references.
HTH
--
Geoff Worboys
Telesis Computing