hallo,
probiert es mal so.
Delphi-Quellcode:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var GR:TGridRect;
begin
with StringGrid1 do
begin
if gdFixed in State
then Canvas.Brush.Color := FixedColor
else Canvas.Brush.Color := Color;
Rect.Top := Rect.Top + 1;
Rect.Left := Rect.Left + 1;
Rect.Right := Rect.Right - 1;
Rect.Bottom := Rect.Bottom - 1;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+2, Rect.Top+2, Cells[ACol, ARow]);
if gdFocused in State
then Canvas.DrawFocusRect(Rect);
end;
end;
procedure TForm1.StringGrid1Exit(Sender: TObject);
var GR:TGridRect;
begin
with GR do begin
GR.Left:=0;
GR.Right:=0;
GR.Top:=0;
GR.Bottom:=0;
end;
StringGrid1.Selection:=GR;
end;
beim verlassen des stringgrid das ereignis exit ausführen