Subject | Re: [IBO] Problems with TIB_Grid colours - Was: Problems updatingacursor |
---|---|
Author | Salvatore Besso |
Post date | 2004-05-24T17:23:40Z |
hello Dmitry,
I have fully resolved, in all aspects, with the following code:
procedure TMainForm.GridGetCellProps(Sender: TObject; ACol, ARow:
Integer;
AState: TGridDrawState; var AColor: TColor; AFont: TFont);
var
Grid: TIB_Grid;
CurDataRow: Integer;
TmpFld: TIB_Column;
begin
{ Row colour change based on the value of a single field }
Grid := Sender as TIB_Grid;
if Assigned(Grid.DataSource) and Assigned(Grid.DataSource.Dataset)
and Grid.DataSource.Dataset.Active and not (gdFixed in AState) then
begin
{ Need to synch }
Grid.DataSource.Dataset.BufferRowNum := Grid.DataRow[ARow];
{ Real data row number }
CurDataRow := Grid.DataSource.Dataset.RowNum;
{ Get the field upon which perform the test }
TmpFld := Grid.DataSource.Dataset.BufferFields.ByName('REJECTED');
if Assigned(TmpFld) and (TmpFld.FieldName = 'REJECTED')
and (TmpFld.AsInteger = 1) then
begin
{ The following is to preserve colour scheme }
{ when in edit state. This means that if we }
{ edit a red row, it becomes yellow }
if (Grid.DataSource.State = dssBrowse)
{ And this is to continue to have red colour }
{ in non edited rows. This means that if we }
{ are editing a non-red row, other red rows }
{ don't change their colour back to white }
{ and stay red }
or (Grid.DataSource.Dataset.BufferRowNum <> CurDataRow) then
begin
AColor := clRed;
if Assigned(AFont) then
AFont.Color := clWhite
end
end
end
end;
Thank you anyway and regards
Salvatore
I have fully resolved, in all aspects, with the following code:
procedure TMainForm.GridGetCellProps(Sender: TObject; ACol, ARow:
Integer;
AState: TGridDrawState; var AColor: TColor; AFont: TFont);
var
Grid: TIB_Grid;
CurDataRow: Integer;
TmpFld: TIB_Column;
begin
{ Row colour change based on the value of a single field }
Grid := Sender as TIB_Grid;
if Assigned(Grid.DataSource) and Assigned(Grid.DataSource.Dataset)
and Grid.DataSource.Dataset.Active and not (gdFixed in AState) then
begin
{ Need to synch }
Grid.DataSource.Dataset.BufferRowNum := Grid.DataRow[ARow];
{ Real data row number }
CurDataRow := Grid.DataSource.Dataset.RowNum;
{ Get the field upon which perform the test }
TmpFld := Grid.DataSource.Dataset.BufferFields.ByName('REJECTED');
if Assigned(TmpFld) and (TmpFld.FieldName = 'REJECTED')
and (TmpFld.AsInteger = 1) then
begin
{ The following is to preserve colour scheme }
{ when in edit state. This means that if we }
{ edit a red row, it becomes yellow }
if (Grid.DataSource.State = dssBrowse)
{ And this is to continue to have red colour }
{ in non edited rows. This means that if we }
{ are editing a non-red row, other red rows }
{ don't change their colour back to white }
{ and stay red }
or (Grid.DataSource.Dataset.BufferRowNum <> CurDataRow) then
begin
AColor := clRed;
if Assigned(AFont) then
AFont.Color := clWhite
end
end
end
end;
Thank you anyway and regards
Salvatore