Subject Re: [IBO] DrawCell method query
Author Lester Caine
> I want to draw over the top of an IB_Grid cell.
> I set the default drawvrfore to true since I want to draw a color rectangle
> marker in the cell depending on the value of an invisible field in the
> query.
> At first I was using
> if (IB_Query1.BufferFieldNyName('myfield').AsBoolean='Y') then
> Draw the rectangle
>
> This worked at first but now I get AV's since it apears that the buffer does
> not have the field in question all the time (when I need it). So I need
> another method of accessing the field value of a record on the current grid
> row (which is not visible).
> I've seen the drawcell code but it only queries the Cell[ARow, ACol] and not
> the contents of an invisible field.
> Can someone lead me to the answer please?

The first question would be - Is 'myfield' always populated?
If some of the entries are still NULL that could be causing
a problem.
I use a more complex version of this, where a hidden state
column gives me an integer to select the colour for the
whole row, and it works well.

//---------------------------------------------------------------------------
void __fastcall TMainForm::ServeGridGetCellProps(TObject
*Sender, int ACol,
int ARow, TGridDrawState AState, TColor &AColor,
TFont *AFont)
{ if ( !ACol || !ARow ) return;
if ( Data->SERVE && Data->SERVE->Active )
{ int BufferRowNum = ServeGrid->DataRow[ ARow ];
if ( BufferRowNum > 0 )
{ Data->INITIAL->BufferRowNum = BufferRowNum;
int wait = -99;
{ if (
Data->SERVE->BufferFieldByName("TWAIT")->IsNotNull )
wait =
Data->SERVE->BufferFieldByName("TWAIT")->AsInteger;
}

This gives me a stable 'TWAIT' what ever I have done with it
in the database <g>

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services