1 (edited by mickeywatsonnn 2020-06-25 12:09:53)

Topic: Coloured coded table

Hi there, I am using the 'invoice' template to build a small project.

I have added a check box that shows delivered orders on the new invoice screen.


Is there any possible way that with this button checked it makes that row in the database table a certain colour & when it is unchecked it is a different colour.


Thank you for your kind help, and I am really enjoying using this software smile

*PS IT WONT LET ME UPLOAD PICTURES sad *

2 (edited by derek 2020-06-25 13:55:49)

Re: Coloured coded table

Hi,
Have a look at the script in the attached project.
It colours the cell in the grid rather than the entire row (which can be a bit overpowering).
I don't know what the issue is with uploading photos but if you attach your project, someone will probably know the answer.
Derek.

Post's attachments

Attachment icon highlightrow.zip 337.9 kb, 294 downloads since 2020-06-25 

Re: Coloured coded table

Thanks Derek, i will have a play around and see what i can do with it and get back to you smile

Re: Coloured coded table

Good morning Derek,
I followed your guidelines and was able to colour an entire row when a cell entry is "Yes".It looks great! However in another project, I want a cell to change to different colours when it's value falls in different ranges say 11-20 or 21-30. How to achieve this? Please help.
Regards,
Eyeman

Post's attachments

Attachment icon tg_colour.zip 229.03 kb, 253 downloads since 2020-07-10 

5 (edited by CDB 2020-07-10 07:28:14)

Re: Coloured coded table

Hi eyeman303,


I'm sure Derek will be browsing through later,  but if you have downloaded Derek's example above, then all you have to do is build on it slightly.


There are two ways that spring to my mind, you can make a CASE statement (which is just a fancy and neater looking if...then...else) or an if..then...else.

procedure Form1_TableGrid1_OnChange (Sender: TObject);
var  vi, myValue: integer;
begin
  for vi := 0 to form1.tablegrid1.RowCount -1 do
    begin

     myValue := form1.tablegrid1.cell[4,vi].AsInteger;

      case myValue of

          11..20:    form1.tablegrid1.cell[4,vi].color := $0085E873;
       
           21..30:   form1.tablegrid1.cell[5,vi].color := $008080FF;

        end;
    end;
end;

Note I haven't tested the above.

On a clear disk you can seek forever

6 (edited by derek 2020-07-10 16:41:40)

Re: Coloured coded table

Hi Eyeman, Hi Colin,
You could try doing it like this (see attached - note that in the script, the value ranges are enclosed in SQUARE brackets) or as Colin suggests, you can use a 'case' statement instead.
Derek.

Post's attachments

Attachment icon highlightcell.zip 337.94 kb, 265 downloads since 2020-07-10 

Re: Coloured coded table

Hello Colin, Hello Derek,
Both methods give the desired result.  Learnt a lot. Thank you so much.
Regards,
Eyeman

Post's attachments

Attachment icon Tablegrid_rowcolour_3.JPG 174.97 kb, 113 downloads since 2020-07-10