怎样使StringGrid一行选中,并改变背景色

解决方案 »

  1.   

    StringGrid.row:=10;背景色最好不要改了,因为选中后会变蓝色,即使你改为红色也显示不出来。
      

  2.   

    要设置Options属性中的goRowSelect为True,然后StringGrid.Row := 10,改背景色写OnDrawCell事件
    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    var s:String;
    begin
      if (ARow = StringGrid1.Row) and (ACol>=StringGrid1.FixedCols) then
      begin
        StringGrid1.Canvas.Brush.Color := clRed;
        StringGrid1.Canvas.FillRect(Rect);
      end;
    end;