Give focus to a fixed cell in TStringGrid

I have a StringGrid which shows a popup menu when a cell in a fixed column is selected (right-clicked).  I want the selected cell to show it has focus somehow.  I've tried doing a FocusRect on the cell, changing the text in the cell to bold, and changing the color of the cell - none of which seem to work.  I've also tried turning defaultdrawing off and drawing the fixed cells myself, and then giving the selected fixed cell focus, but that also didn't work.  How can I show that the fixed cell has focus when selected?
jpozAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
see if this will help
(default drawing off)



procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
 checked: boolean;
 oldbrush: integer;
 oldpen: tpen;
begin
 with stringgrid1.canvas,rect do
 begin
  oldbrush:=brush.color;
  brush.color:=clyellow;
  oldpen:=pen;
  pen.Width:=2;
  pen.color:=clred;
  moveto(left+1,top+2);
  polygon([point(left,top),
           point(left,bottom),
           point(right,bottom),
           point(right,top),
           point(left,top)]);
  checked:=boolean(stringgrid1.Objects[acol,arow]);
  if checked then
  begin
  brush.Color := clblue;
  polygon([point(left,top),
           point(left,bottom),
           point(right,bottom),
           point(right,top),
           point(left,top)]);
  end;
  brush.color:=oldbrush;
  textout(left+17,top+4,stringgrid1.cells[acol,arow]);
  pen:=oldpen;
 end;
end;

procedure TForm1.StringGrid1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
 r,c: integer;
 checked: boolean;
begin
 with stringgrid1 do
 begin
  mousetocell(x,y,c,r);
  checked:=(longint(objects[c,r])<>0);
  if checked then objects[c,r]:=pointer(0) else objects[c,r]:=pointer(1);
 end;
 end;

 

Regards Barry
0
 
jpozAuthor Commented:
I had to tweak it a little to work for my app, but it worked, thanks!
0
All Courses

From novice to tech pro — start learning today.