在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;