Can I remove focus rectangle around the selected cell in StringGrid when
DefaultDrawing = True
Thanks.
procedure TForm1.StringGrid1Exit(Sender: TObject);
Var
Rc : TGridRect;
begin
Rc.Left := -1;
Rc.Top := -1;
Rc.Right := -1;
Rc.Bottom := -1;
StringGrid1.Selection := Rc;
end;
Your sample is cool, but I want remove dot-mark from active cell?
Thanks.
if gdFocused in State then
with Rect do begin
StringGrid1.Canvas.Rectangle( Left, Top, Right, Bottom);
StringGrid1.Canvas.Textout( Left+2, Top+2,
StringGrid1.Cells[ACol,ARow]);
end;
This is off the top of my head so you'll have to deal with the syntax.
Good luck.
If you use DrawFocustRect() at the end of your OnDrawCell it will draw a
focus rect that will be canceled out after the OnDrawCell when the VCL does
a DrawFocusRect() again.
Olivier
procedure TMiscForm.StringGrid1DrawCell(Sender: TObject;
ACol, ARow: Integer;
Rect : TRect;
State : TGridDrawState);
var SG: TStringGrid;
begin
if Sender is TStringGrid then begin
SG:= TStringGrid(Sender);
with SG.Canvas do begin
Font:= SG.Font;
Brush.Color:= SG.Color;
Brush.Style:= bsSolid;
if gdFixed in State
then begin
Brush.Color:= SG.FixedColor;
end;
if ( gdSelected in State)
and not (gdFocused in State)
then begin
Brush.Color:= clHighLight;
Font.color := clHighLightText;
end;
Pen.Color := Brush.Color;
Pen.Mode := pmCopy;
Pen.Style := psSolid;
Pen.Width := 1;
Rectangle(Rect);
if Ctl3D
and (gdFixed in State)
then begin
if goFixedVertLine in SG.Options
then begin
Pen.Color := clBtnHighLight;
MoveTo(Rect.Left, Rect.Bottom-1);
LineTo(Rect.Left, Rect.Top);
Pen.Color := clBtnShadow;
MoveTo(Rect.Right-1, Rect.Top);
if goFixedHorzLine in SG.Options
then LineTo(Rect.Right-1, Rect.Bottom)
else LineTo(Rect.Right-1, Rect.Bottom+SG.GridLineWidth);
end;
if goFixedHorzLine in SG.Options
then begin
Pen.Color := clBtnHighLight;
MoveTo(Rect.Left, Rect.Top);
LineTo(Rect.Right, Rect.Top);
Pen.Color := clBtnShadow;
if goFixedVertLine in SG.Options
then begin
MoveTo(Rect.Left+1, Rect.Bottom-1);
LineTo(Rect.Right, Rect.Bottom-1)
end else begin
MoveTo(Rect.Left, Rect.Bottom-1);
LineTo(Rect.Right+SG.GridLineWidth, Rect.Bottom-1);
end;
end;
end;
Brush.Style:= bsClear;
TextRect( Rect, Rect.Left+2, Rect.Top+2, SG.Cells[ACol,ARow]);
Brush.Style:= bsSolid;
if gdFocused in State then DrawFocusRect(Rect);
end;
end;
end;