Topic: Grid row coloring

Hi Guys,


The following for single cell coloring. What would I change to color:
1 Whole row
2 More than one cell on same row


if Form1.tgInvSearch.Cells[7,i] = 'No' then Form1.tgInvSearch.Cell[7,i].Color := $00DDDDFF;
Adam
God... please help me become the person my dog thinks I am.

Re: Grid row coloring

Hello.


1. Whole row

var
   q, iCol: integer;
begin
     q := Form1.TableGrid1.Columns.Count-1;
     for iCol := 0 to q do
        Form1.TableGrid1.Cell[iCol,i].Color :=  $00DDDDFF;


2.

if Form1.tgInvSearch.Cells[7,i] = 'No' then 
begin
   Form1.tgInvSearch.Cell[7,i].Color := $00DDDDFF;
   Form1.tgInvSearch.Cell[2,i].Color := $00DDDDFF; 
   Form1.tgInvSearch.Cell[9,i].Color := $00DDDDFF;
end;
Dmitry.

Re: Grid row coloring

Hi Dmitry,


Thank you very much....


Number 2 was easy, but couldn't apply whole row script correctly


//Coloring tgrid WHOLE row
procedure frmLookups_tgProd_CodePrefix_OnChange (Sender: string);
var
   q, iCol: integer;
   begin
      q := frmLookups_tgProd_CodePrefix.Columns.Count-1;
      for iCol := 0 to q do
      if frmLookups.tgProd_CodePrefix.Cells[2,i] = 'No' then
        begin
        frmLookups_tgProd_CodePrefix.Cell[iCol,i].Color :=  $00DDDDFF;
        end;
   end;
Adam
God... please help me become the person my dog thinks I am.

Re: Grid row coloring

AD1408

procedure frmLookups_tgProd_CodePrefix_OnChange (Sender: string);
var
   iRow ,c: integer;
   q, iCol: integer;
begin
     c := frmLookups.tgProd_CodePrefix.RowCount - 1;
     q := frmLookups.tgProd_CodePrefix.Columns.Count-1;
     for iRow := 0 to c do
        if frmLookups.tgProd_CodePrefix.Cells[2,iRow] = 'No' then
            for iCol := 0 to q do frmLookups.tgProd_CodePrefix.Cell[iCol,iRow].Color := $00DDDDFF;
         
end;   
Dmitry.

Re: Grid row coloring

Hi Dmitry,


Thank you very much..... All good now.

Adam
God... please help me become the person my dog thinks I am.

Re: Grid row coloring

What about changing text color only of a whole row on tGrid please.........

Adam
God... please help me become the person my dog thinks I am.

Re: Grid row coloring

AD1408 wrote:

What about changing text color only of a whole row on tGrid please.........

Instead

frmLookups.tgProd_CodePrefix.Cell[iCol,iRow].Color

use

frmLookups.tgProd_CodePrefix.Cell[iCol,iRow].TextColor
Dmitry.

Re: Grid row coloring

Thanks a lot Dmitry.............


I wanted to apply conditional coloring of whole row / text of tGrid to combobox value by changing boolean value (yes, no) to available combobox value, It didn't work.

Adam
God... please help me become the person my dog thinks I am.

Re: Grid row coloring

AD1408 wrote:

Thanks a lot Dmitry.............


I wanted to apply conditional coloring of whole row / text of tGrid to combobox value by changing boolean value (yes, no) to available combobox value, It didn't work.

procedure frmLookups_tgProd_CodePrefix_OnChange (Sender: string);
var
   iRow ,c: integer;
   q, iCol: integer;
begin
     c := frmLookups.tgProd_CodePrefix.RowCount - 1;
     q := frmLookups.tgProd_CodePrefix.Columns.Count-1;
     for iRow := 0 to c do
        if frmLookups.tgProd_CodePrefix.Cells[2,iRow] = 'No' then
            for iCol := 0 to q do frmLookups.tgProd_CodePrefix.Cell[iCol,iRow].TextColor := $00DDDDFF;
         
end;   
Dmitry.

Re: Grid row coloring

Thanks a lot Dmitry for the highlight........


I was putting the script in wrong place. The following seems to be working OK:

//Coloring tgrid WHOLE row boolean and comboboxes
procedure Form1_tgSearch_OnChange (Sender: string);
var
   iRow ,c: integer;
   q, iCol: integer;
begin
     c := Form1.tgSearch.RowCount - 1;
     q := Form1.tgSearch.Columns.Count-1;
     for iRow := 0 to c do
        if Form1.tgSearch.Cells[2,iRow] = 'Yes' then
            for iCol := 0 to q do Form1.tgSearch.Cell[iCol,iRow].TextColor := $00959595;

        //Coloring tgrid WHOLE row TEXT according to combobox Repeat Every cbDetailsRepeat...
        for iRow := 0 to c do
        if Form1.tgSearch.Cells[3,iRow] = '3 Months' then
            for iCol := 0 to q do Form1.tgSearch.Cell[iCol,iRow].TextColor := clGreen;

        //Coloring tgrid WHOLE row TEXT according to combobox Month cbDetailsMonth
        for iRow := 0 to c do
        if Form1.tgSearch.Cells[4,iRow] = 'May' then
            for iCol := 0 to q do Form1.tgSearch.Cell[iCol,iRow].TextColor := clPurple;

        //Coloring tgrid WHOLE row TEXT according to combobox Day cbDetailsDay
        for iRow := 0 to c do
        if Form1.tgSearch.Cells[5,iRow] = 'Sunday' then
            for iCol := 0 to q do Form1.tgSearch.Cell[iCol,iRow].TextColor := clRed;

end;
Adam
God... please help me become the person my dog thinks I am.