1,2 ???
3.下面两种方法可以使焦点所在cell有一个红色边框:
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
(Sender as TDbGrid).Canvas.Font.Color := clRed ;
// (Sender as TDbGrid).Canvas.pen.Color := clRed ;
(Sender as TDbGrid).Canvas.brush.Color := clRed ;
if state=[gdFocused] then
(Sender as TDbGrid).DefaultDrawDataCell(Rect, Field ,State);
end;
或者:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
(Sender as TDbGrid).Canvas.Font.Color := clRed ;
// (Sender as TDbGrid).Canvas.pen.Color := clRed ;
(Sender as TDbGrid).Canvas.brush.Color := clRed ;
if state=[gdFocused] then
(Sender as TDbGrid).DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;