你这样做会有很多问题的;给你写点代码,可能对你有帮助;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
ARect:TRect;
begin
if (gdFocused in State) and (column.Index=0) then
begin
begin
checkbox1.BringToFront;
ARect.Left:=Rect.Left + DBGrid1.Left + 1+(Rect.Right-Rect.Left-Checkbox1.Width) div 2;
ARect.Top:=Rect.Top + DBGrid1.Top + 2;
ARect.Right:=(Rect.Right - Rect.Left- checkbox1.Width) div 2-13;
ARect.Bottom:=(Rect.Bottom - Rect.Top-13) div 2 +13 ;
checkbox1.SetBounds (ARect.Left, ARect.Top, ARect.Right,ARect.Bottom);
end;
end;
end;
procedure TForm1.DBGrid1ColEnter(Sender: TObject);
begin
if dbgrid1.SelectedIndex=0 then
checkbox1.visible:=true
else
checkbox1.visible:=false;
end;