在Delphi中的DataGrid怎樣使它顯示的行間隔改變顏色?就向.Net中同名控件一樣。
---------------------------------------------------------------
好像是在 OnDrawDataCell 事件中寫代碼。
---------------------------------------------------------------
procedure TForm1.dbgridDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DBGrid2.DataSource.DataSet.RecNo mod 2=1 then
begin
DBGrid2.Canvas.Font.Color := clBlue;
DBGrid2.Canvas.Brush.Color:=clyellow;
end
else begin
DBGrid2.Canvas.Font.Color := clred;
DBGrid2.Canvas.Brush.Color:= clGradIEntActiveCaption;
end;
DBGrid2.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;