In your database you must have a field where you indicate if the value is an expense or revenue. Let’s say the name of this field is called 'guy'. You can change the colors like this:
Two clicks on the event onDrawColumnCell of your Dbgrid
If tabelaTIPO.Value = 'despesa' then // condição
begin
Dbgrid1.Canvas.Font.Color:= clRed; // coloque aqui a cor desejada
Dbgrid1.DefaultDrawDataCell(Rect, dbgrid1.columns[datacol].field, State);
end else
begin
Dbgrid1.Canvas.Font.Color:= clGreen; // coloque aqui a cor desejada
Dbgrid1.DefaultDrawDataCell(Rect, dbgrid1.columns[datacol].field, State);
end;
What the code does is to check if in the TYPE field of your table is 'expense', paint red, or paint green. But you can choose the color you want.
In the example I quoted, I made a condition using a string to facilitate, but recommend using a field integer 0 for expenditure and 1 for revenue.
would be a color for expense and another for revenue?
– Italo Rodrigo
Yes, as I decided to record the expenses and revenues in the same table, I want to differentiate in dbGrid
– nicolasz