当点击stringgrid中的一行时,怎样让该行字体的颜色变成想要的颜色?

解决方案 »

  1.   

    找别的控件,如StringGridAlign应该是这样写的
      

  2.   

    procedure TForm2.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
       if ARow=StringGrid1.Row then
         begin
          StringGrid1.Canvas.Brush.Color:=clred;
          StringGrid1.Canvas.FillRect(Rect);
          StringGrid1.Canvas.TextOut(Rect.left,Rect.top,StringGrid1.Cells[Acol,Arow]);
         end;end;
      

  3.   

    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
        if (acol=1) and (arow=2) then
        begin
            StringGrid1.Canvas.Font.Color:=clred;
            StringGrid1.Canvas.TextRect(Rect,Rect.Left,Rect.Top,StringGrid1.Cells[Acol,arow]);
        end;
    end;