StringGrid remove rectangle...

I'm using StringGrid. How can I remove rectangle around the selected cell, but not in fixed row.If I use stringgrid1.DefaultDrawing:=false i lost 3d efect in fixed row.
Thank you.
nikola_mkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wim ten BrinkSelf-employed developerCommented:
I've checked the sourcecode in Delphi 5... You can't!... :-(
You will have to draw the contents yourself. But if you disable DefaultDrawing, set GridLineWidth to 0 and just want to keep it simple, you could use this:

procedure TFormMain.StringGrid1DrawCell( Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState );
begin
  if ( ACol < StringGrid1.FixedCols ) or ( ARow < StringGrid1.FixedRows ) then begin
    StringGrid1.Canvas.Pen.Color := clBtnText;
    StringGrid1.Canvas.Brush.Color := clBtnFace;
    StringGrid1.Canvas.FillRect( Rect );
    DrawEdge( StringGrid1.Canvas.Handle, Rect, EDGE_RAISED, BF_RECT or BF_ADJUST );
  end
  else begin
    StringGrid1.Canvas.Pen.Color := clWindowText;
    StringGrid1.Canvas.Brush.Color := clWindow;
    StringGrid1.Canvas.FillRect( Rect );
  end;
  StringGrid1.Canvas.TextRect( Rect, Rect.Left + 2, Rect.Top + 2, StringGrid1.Cells[ ACol, ARow ] );
end;

It will draw the nice 3D edge and you can actually choose which edge you like. The BF_ADJUST is there because the GridLineWidth is 0. (It adjusts the rectangle borders by making it one pixel smaller on all sides.) If you do want those gridlines, just remove BF_ADJUST else you will get a thick border.

Of course, if you use
   DrawEdge( StringGrid1.Canvas.Handle, Rect, EDGE_RAISED, BF_RECT or BF_ADJUST );
for ALL the cells, they will all get a nice 3D view.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.