Subject Re: [IBO] GetDisplayText... How does it work?
Author Helen Borrie
At 02:49 PM 19/11/2004 +0100, you wrote:

>Helen Borrie wrote:
> >You need to operate on the Row object to ensure that the timing is correct
> >(and, of course, if there is no row, nothing happens, so you don't have to
> >test its cardinality!). The one thing you do need to take care about, is
> >not to cause it to be called when the dataset is not in a Prepared state.
> >
> >procedure TfrmMain.IB_GridBarzeGetDisplayText( Sender: TObject; ACol,
> > ARow: Integer; var AString: string );
> >begin
> > with ARow do begin
> > if ACol = 3 then
> > AString := LeftStr(ByName('TESTO').AsString), 20);
> >end;
> >
> >
> >
>Thanx Helen
>But ARow is a Integer :-)

Oh, yes!! I must stop answering these posts so late at night! These are
the grid row and col references, not the dataset row, and of course
cell-painting is taking place row-by-row. The method is saying: whenever
you go to repaint the grid, use this data for the text whenever you hit
grid column 3.

Now, the problem we have to solve here is: how to access the row of the
dataset that is current at the time that cell is being painted. We need to
find a way to do that.

The cell's row number is no use to us, since there is no guarantee that the
grid's row is the same as the buffer's row - because of "horizontal dataset
refinement", the current "window" of the buffer that the grid is displaying
might start anywhere in the buffer.

The cell's Col property doesn't necessarily give us the column's position
in the ib_row (Fields[n]) either, because some Fields[] members may not be
visible. So our code has to know in advance the FieldName of the column
that is going to be displayed when ACol is 3.

>How I Can access to the "Row Object"?

At this late hour, I cannot think of a way. I don't think trying to get at
it from the grid is the way you are going to solve it. The dataset drives
the grid, not the other way around.

My best guess right now is that you will need to define a calculated field
to display this fragment. Access the Row object in the OnCalculateFields

Another dimension of all this, of course, is that you will need to pull all
of the blobs over to the client, rather than call them over on demand.

Sorry not to have the Magic Bullet. :-( Perhaps someone more awake will
come up with something brilliant....