Subject Re: OnDrawCell handler
Author Sergey Kanovka
Hi,

I also have problem with custom drawing. I can not use method
suggested by Ingo, because I do not show in grid column which value I
use as a base for drawing bitmap.

IB_Query.FieldByName does not work. Is there another way to obtain a
current value of particular field of dataset attached to grid?

Wednesday, November 29, 2000, 2:00:30 AM, you wrote:

Ingo Jansen> Hi Tomas,

Ingo Jansen> i have the same problem when i want to draw a image in the cell. I
Ingo Jansen> changed my code that way that dont use the dataset.fieldbyname
Ingo Jansen> ('').value, i use something like this -
Ingo Jansen> if strtoInt(TIB_Grid(Sender).GetCellDisplayText(aCol,ARow))=2 then
Ingo Jansen> begin
Ingo Jansen> TIB_Grid(Sender).Canvas.Font.Color := clRed;
Ingo Jansen> TIB_Grid(Sender).DefaultDrawCell(ACol, ARow, Rect, State,...
Ingo Jansen> end;
Ingo Jansen> and then i the problem was solved. i hope it's a solution for your
Ingo Jansen> prolem too.

Ingo Jansen> --- In IBObjects@egroups.com, Tomas MichalĂ­k <michalik@p...> wrote:
>> Hi all,
>>
>> It is the first time I tried to do custom drawing in grid and I
Ingo Jansen> haven't
>> succeded :-(
>> Here is the handler - it is only test:
>>
>> procedure TfTransfer.IB_Grid1DrawCell(Sender: TObject; ACol, ARow:
>> Integer;
>> Rect: TRect; State: TGridDrawState);
>> begin
>> if TIB_Grid(Sender).DataSource.Dataset.Active then
>> begin
>> if TIB_Grid(Sender).GridFields[ACol-1].FieldName
Ingo Jansen> = 'PRP_MNOZSTVI'
>> then
>> if
>> TIB_Grid(Sender).DataSource.Dataset.FieldByName
Ingo Jansen> ('PRP_MNOZSTVI').AsCurrency
>> = 2 then
>> begin
>> TIB_Grid(Sender).Canvas.Font.Color := clRed;
>> TIB_Grid(Sender).DefaultDrawCell(ACol, ARow, Rect, State,
>>
>> TIB_Grid(Sender).DataSource.Dataset.FieldByName
Ingo Jansen> ('PRP_MNOZSTVI').AsString,
>> taCenter);
>> end;
>> end;
>> end;
>>
>> I want to change the font color to clRed in all the cells where the
>> value of column PRP_MNOZSTVI is 2. My code works in a different
Ingo Jansen> way. It
>> changes the font color only when the row that meets the condition is
>> active/selected. But in such a case it changes the font color and
Ingo Jansen> fills
>> this value into all rows for this column.
>> How do I get the actual field values for the row that is currently
Ingo Jansen> being
>> painted in a grid ?
>>
>> P.S. I think it worked when I used similar solution long time ago
Ingo Jansen> with
>> TDBGrid and TTable.
>>
>> Best regards,
>> Tom
>>

Serge