Topic: Display cell in colour instead

I have column (named Cost) in database, with 3 letters A,B and C. I would like to replace these letters so that the colour is displayed instead the letters themselves. How to approach this?

Here is visual example. There are two columns named Cost, ignore the one that shows the letters A, B, C. This is just to show data I currently have. I would like it to display as on the right side (column Cost), where you see 3 set of different colours.

Thanks.

Post's attachments

Attachment icon example.png 46.87 kb, 253 downloads since 2015-08-21 

Re: Display cell in colour instead

Please attach your project (zip file without exe and dll)
I'll try to help you.

Dmitry.

Re: Display cell in colour instead

Hello riskmeter, Dmitry

In a phone book application made with MVD, I used this way to show different user groups
(green for family, red for health, blue for services and so on);

This is my code for that :


procedure Accueil_Grille_Contacts_OnChange (Sender: string);
var  i,c,q     : integer;
     iRow,iCol : integer;
begin
 
   c := Accueil.Grille_Contacts.RowCount - 1;
    for i := 0 to c do
    begin
        If Accueil.Grille_Contacts.Cells[4,i] = 'Family' then Accueil.Grille_Contacts.Cell[4,i].Color  := clGreen;     // The 5th column
           Accueil.Grille_Contacts.Cell[4,i].TextColor := clWhite;
        If Accueil.Grille_Contacts.Cells[4,i] = 'Health' then Accueil.Grille_Contacts.Cell[4,i].Color    := clRed;
           Accueil.Grille_Contacts.Cell[4,i].TextColor := clWhite;
        If Accueil.Grille_Contacts.Cells[4,i] = 'Various'  then Accueil.Grille_Contacts.Cell[4,i].Color   := clMaroon;
           Accueil.Grille_Contacts.Cell[4,i].TextColor := clWhite;
        If Accueil.Grille_Contacts.Cells[4,i] = 'Office' then Accueil.Grille_Contacts.Cell[4,i].Color   := clOlive;
           Accueil.Grille_Contacts.Cell[4,i].TextColor := clWhite;
        If Accueil.Grille_Contacts.Cells[4,i] = 'Services' then Accueil.Grille_Contacts.Cell[4,i].Color := clBlue;
           Accueil.Grille_Contacts.Cell[4,i].TextColor := clWhite;
    end;
end;

Here, I give color for cells with same value and above all, I give a white color to value text so that it comes out better on color.

Does that answer your question ?

Thanks

JB