RE: TZF - TzGrid Colors

Alex Mackinnon <[email protected]> Thu, 6 Nov 2003 16:46:36 -0000
Newsgroups gmane.comp.lang.delphi.topaz
Message-ID <[email protected]>
Variant No. 2 (another possibility of what you might be trying to do...)

This version uses just one dataset the one attached to the grid itself.
You can set the highlighted record using the property 'MasterRecordNo'.
If 'MasterRecordNo' is set to -1 (or any value less than 0) then no
highlighting is done.

In case anyone needs to know you need to install this component to the
palette using
'Component|Install Component' from the Delphi menu.
Regards,
A.

===================================================================
unit descdemo;

interface

uses
  Windows, Graphics, Classes, DB, Grids, DbGrids, tzprimds, ucommon,
  utzcds, utzfds, atzgrids;

type
  TTzGridRC=class(TTzGrid)
  private
    _masterrecordno:Integer;
    procedure ChangeColors(Sender: TObject; curRow: Integer;
      var IndicatorColor, CellColor, CellTextColor, HiliteColor,
      HiliteTextColor, DeletedColor, DeletedTextColor: TColor);
    procedure WriteMRNo(rn:Integer);
  public
    constructor Create(AOwner: TComponent); override;
  published
    property MasterRecordNo:Integer read _masterrecordno write
WriteMRNo;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('SSI', [TTzGridRC]);
end;

{ TTzGridRC }

procedure TTzGridRC.ChangeColors(Sender: TObject; curRow: Integer;
  var IndicatorColor, CellColor, CellTextColor, HiliteColor,
  HiliteTextColor, DeletedColor, DeletedTextColor: TColor);
begin
  if Assigned(DataSource) and Assigned(DataSource.DataSet)
    and (_masterrecordno>=0) then
  begin
    if _masterrecordno=DataSource.DataSet.RecNo then
    begin
//         CellColor:=$00B3A8FF;
         CellColor:=$0033FFFF;
         DeletedColor:=clRed;
         HiliteColor:=$00ffff01;
         CellTextColor:=clBLACK;
         HiliteTextColor:=clBLACK;
//         Canvas.Font.Style:=Canvas.Font.Style+[fsBold];
//         Canvas.Font.Size:=12;
    end
    else
    begin
          CellColor:=$00B3F8FF;
          HiliteColor:=$00B3F8FF;
          CellTextColor:=clBlack;
          HiliteTextColor:=clBlack;
//         Canvas.Font.Style:=Canvas.Font.Style-[fsBold];
//         Canvas.Font.Size:=8;
    end;
  end;
end;

procedure TTzGridRC.WriteMRNo(rn: Integer);
begin
  _masterrecordno:=rn;
  RefreshGrid;
end;

constructor TTzGridRC.Create(AOwner: TComponent);
begin
  inherited;
  _masterrecordno:=-1;
  OnChangeColorsEvent:=ChangeColors;
end;

end.

--^----------------------------------------------------------------
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]

TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
--^----------------------------------------------------------------