掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
DBGridの背景色の反転について (ID:30375)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
こんな感じになるのですかね? コンポーネントに組み込むなら public部のWmKeyDownを組み込んでください。 その際にMessages等を組み込まないと 色々と「未定義です」と怒られるのでご注意ください。 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, DBGridEx, DB, DBTables, StdCtrls; type TDBGridEx = class(DBGridEx.TDBGridEx) //クラスの参照先は私とは違うかもしれないので調べてください private protected public procedure WmKeyDown(var Msg: TMessage); Message WM_KEYDOWN; published end; TForm1 = class(TForm) DBGridEx1: TDBGridEx; procedure DBGridEx1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); private { Private 宣言 } public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.dfm} { TDBGridEx } procedure TDBGridEx.WmKeyDown(var Msg: TMessage); begin inherited; with Form1.DBGridEx1 do begin case LOWORD(Msg.wParam) of VK_DOWN, VK_UP: //ここ適当です。 begin Invalidate; end; end; end; end; procedure TForm1.DBGridEx1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var C : TColor; begin if (DBGridex1.SaveRow mod 2) = 0 then C := clSkyBlue else C := clWindow; DBGridEx1.Canvas.Brush.Color := C; DBGridEx1.DefaultDrawColumnCell(Rect,DataCol,Column,State); end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.