Board index » delphi » Stringgrid , DBgrid question

Stringgrid , DBgrid question

Is there a way to change the color of a cell not the column or row

I need to click on a cell and then make that cell turn red.

any help

thanks

 

Re:Stringgrid , DBgrid question


For StringGrid, see OnDrawCell event.

For DBGrid, see OnDrawColumnCell and OnDrawDataCell events.

Joseph Liu

Quote
"Gildardo" <Gilda...@hmo.megared.net.mx> wrote in message

news:3b3e7506_2@dnews...
Quote
> Is there a way to change the color of a cell not the column or row

> I need to click on a cell and then make that cell turn red.

> any help

> thanks

Re:Stringgrid , DBgrid question


For a DBGrid use the OnDrawColumnCell event.

if Column.FieldName = 'MyField' then
begin
  Canvas.Brush.Color := clSilver; {Sets background color}
  Canvas.Font.Color := clBlue; {Sets font color}
  DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;

A StringGrid is similar.

--
Bill

Other Threads