在DrawCell中就可以呀,在该事件判断是否选中了一个cell,如果选中就画一个图标
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  if gdSelected in State then
    StringGrid1.Canvas.Draw(Rect.Left, Rect.Top, Image1.Picture.Graphic);
end; 

解决方案 »

  1.   

    我的StringGrid的整行选择属性设置成了true,当我在选中一行后可以在指定的Cell中显示一个icon,可是当我选中另外一行后,当前行的指定Cell中也可以显示一个icon,可是上一行的icon就不见了。我想实现下面的效果:
    当选中一行后,如果当前行的指定Cell为空就显示一个icon,如果已经有一个icon了就去掉这个icon,显示空,不过此操作对别的行没有影响,别的行如果有icon依旧让它显示。
      

  2.   

    搞定了。
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs, Graphics,
      Grids, ExtCtrls;type
      TForm1 = class(TForm)
        StringGrid1: TStringGrid;
        Image1: TImage;
        procedure FormCreate(Sender: TObject);
        procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
          Rect: TRect; State: TGridDrawState);
        procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
          var CanSelect: Boolean);
      private
        { Private declarations }
        FDraw: array of boolean;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    begin
      SetLength(FDraw, StringGrid1.RowCount);
    end;procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    var
      i: integer;
    begin
      for i := 1 to StringGrid1.RowCount - 1 do
        if FDraw[ARow] and (ACol = 3) and (ARow <> i) then
          StringGrid1.Canvas.Draw(Rect.Left, Rect.Top, Image1.Picture.Graphic);
    end;procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
      ARow: Integer; var CanSelect: Boolean);
    var
      ARect: TRect;
    begin
      with StringGrid1 do
      begin
        ARect := CellRect(ACol, ARow);
        if (ARow <>0) and (ACol <> 0) then
          if not FDraw[ARow]  then
          begin
            Canvas.Draw(ARect.Left, ARect.Top, Image1.Picture.Graphic);
            FDraw[ARow] := true;
          end
          else begin
            Canvas.Draw(ARect.Left, ARect.Top, nil);
            FDraw[ARow] := false;
          end;
      end;
    end;end.
      

  3.   

    哥们,你真够意思,冲你这么热心,这分也得给你,能留个EMail吗?有问题再找你。