Subject RE: [IBO] DrawCell method query
Author Alan McDonald
thanks Lester,
no my fields are all populated - they are not null boolean Y/N fields
I have since found that
if (IB_Query1.BufferFields[4].AsString='Y') then
works where
if (IB_Query1.BufferFieldByName('myboolfield').AsBoolean='Y') then
does not

Not sure why... any clues?
secondly
what is the difference between using the DrawCell event and the GetCellProps
event for doing this task?
Why is there a DrawCell and DrawFocusedCell when you can test for focused
state in the DrawCell event anyway?

thanks
Alan

-----Original Message-----
From: Lester Caine [mailto:lester@...]
Sent: Tuesday, 4 February 2003 6:44 PM
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] DrawCell method query


> 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



___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/