Topic: tableGrid color

how to change group color?

Post's attachments

Attachment icon 90UB310.jpg 118.29 kb, 104 downloads since 2020-02-04 

Re: tableGrid color

Set property HeaderStyle = hsFlatBorder and use this code:

procedure frmMain_TableGrid1_OnChange (Sender: TObject);
begin
  frmMain.TableGrid1.Columns[0].Header.Color := clRed;
end;

You can change only header background color, header font color = table font color

Визуальное программирование: блог и телеграм-канал.

3 (edited by amir-t 2020-02-04 12:05:21)

Re: tableGrid color

I need to paint the row according to the selected group

Re: tableGrid color

Hello amir-t

Can this snippet help you ?

procedure Form1_GridEmployees_OnChange (Sender: string);
var    i,c: integer;
   k, q: integer;
begin
    // Form1.GridEmployees.Columns[3].Visible := False; // hide column
     c := Form1.GridEmployees.RowCount - 1;
     q := Form1.GridEmployees.Columns.Count - 1;
     for i := 0 to c do
     begin
         if Form1.GridEmployees.Cells[3,i] = 'Yes' then
            for k := 0 to q do Form1.GridEmployees.Cell[k,i].Color := clRed;
         if Form1.GridEmployees.Cells[3,i] = 'No' then
            for k := 0 to q do Form1.GridEmployees.Cell[k,i].Color := clGreen;
     end;
end;

JB