:
アンOnDrawColumnCellイベントハンドラは セル内のデータ値を書き込むデータ対応グリッドを指示するDefaultDrawColumnCell メソッドを呼び出すことができます。
DefaultDrawColumnCellをこのように使用します。これはDelphiコードですが、簡単に変換できます。
procedure TForm1.DBGridDrawColumnCell(Sender: TObject;const Rect: TRect;
DataCol: Integer; Column: TColumnEh;State: TGridDrawState);
begin
.....
DBGrid.Canvas.Brush.Color := clBlue;
DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
....
dgRowSelectまたはdgMultiSelectを設定せずに、DBGridのアクティブな行をペイントする方法更新
。
- 現在の行の先頭位置を取得する必要があります。
CellRect、コルを作成し、公共の行にクラスにのTDBGridのinheritantを定義します。
type
TMyDBGrid = class(TDBGrid)
public
function CellRect(ACol, ARow: Longint): TRect;
property Col;
property Row;
end;
function TMyDBGrid.CellRect(ACol, ARow: Longint): TRect;
begin
Result := inherited CellRect(ACol, ARow);
end;
今、私たちはOnDrawColumnCellイベントで、現在のセルの上部を確認することができます。
procedure TMainForm.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var Col,Row : Integer;
begin
col := TMyDbGrid(DBGrid1).Col;
row := TMyDbGrid(DBGrid1).Row;
if (Rect.Top = TMyDBGrid(DBGrid1).CellRect(Col,Row).Top) and
(not (gdFocused in State) or not Focused) then
DBGrid1.Canvas.Brush.Color := clBlue;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
こんにちは友人を、お返事いただきありがとうございます。私はすでにこの種のコードを使用しており、すでに行をペイントしています。私が知る必要があるのは、ACTIVE ROWだけをペイントする方法と、dgRowSelectまたはdgMultiSelectを設定しないことです。つまり、アクティブな行を決定する方法(State.Contains(gdSelected)とグリッド - > SelectedRows-> CurrentRowSelectedはこの場合は機能しません) – sgm
@sgm uptateを参照してください –
Focused var! – sgm