Re:How to higlight a row on a TDBGrid using the OnDrawColumnCell event in Delphi2
Quote
> I have a TDBgrid on a form, and a search button. After the search is
> successfull, the cursor of the DBGrid moves to the newlly selected record.
> I want to highlight the result in the grid. I think that I have to use the
> OnDrawColumnCell event of the DBgrid object, but I can't get any infos on
> how to do it.
> Any clues ?
> Thanks for your help
> Tony
I was successful implementing it like this in the OnDrawDataCell event:
The user selects the Menu Option "HighLight Unpaid Invoices", if the
"BalanceDue" field value is > 0, then that row of the DBGrid getshighlighted in
RED;
procedure TInvoiceListingForm.InvoiceGridDrawDataCell(Sender: TObject;
const Rect: TRect; Field: TField; State: TGridDrawState);
begin
if NegativeBalance2 = True then
if InvoiceTableBalanceDue.Value > 0 then
InvoiceGrid.Canvas.Brush.Color:= clRed;
InvoiceGrid.Canvas.FillRect(Rect);
InvoiceGrid.Canvas.TextOut(Rect.left + 2, Rect.top + 2,Field.DisplayText);
end;
Hope that helps!
----
RKR
****************************************
E-Mail: r...@primenet.com
****************************************