掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
DBGridの背景色に一行置きに色をつけるには? (ID:28688)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ソース ---------------------------------------------------- unit DBGridEx; interface uses Windows, Classes, Grids, DBGrids; type TDBGridEx = class(TDBGrid) private FSaveRow : Integer; FSaveCol : Integer; protected public procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);override; published property SaveRow : Integer read FSaveRow; property SaveCol : Integer read FSaveCol; end; procedure Register; implementation procedure TDBGridEx.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); begin FSaveRow := ARow; FSaveCol := ACol; //継承元のDrawCellを実行する inherited; end; procedure Register; begin //Componentパレットに TDBGridEx が登録される RegisterComponents('Component', [TDBGridEx]); end; end. ------------------------------------------------ そして procedure TForm1.DBGridEx1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var C : TColor; begin if (SaveRow mod 2) = 0 then C := clRed else C := clBlue; DBGridEx1.Canvas.Brush.Color := C; DBGridEx1.DefaultDrawColumnCell(Rect,DataCol,Column,State); end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.