说具体点可以吗?
赋值是这么写的
cells[0,0]:='aa';
可是写颜色怎写?

解决方案 »

  1.   

    示例如下:
    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      with Sender as TstringGrid do
      begin
      Canvas.Brush.Color := clyellow;//BackGround;
      Canvas.FillRect( stringgrid1.CellRect(1,1));  end;
    end;
      

  2.   

    兄弟不可以的,
      begin
      with Sender as TstringGrid do
      Canvas.Brush.Color := clyellow;
      Canvas.FillRect(stringgrid1.CellRect(1,1));
     
      只是给鼠表单击的单元边框加了红色,我要的是单元格的背景是红色的.
    而且根据单元中内容不同背景色也要不同我的功能可以实现吗?
      

  3.   

    with Sender as TstringGrid do
    begin
      Canvas.Brush.Style := bsSolid;
      Canvas.Brush.Color := clyellow;
      Canvas.FillRect(stringgrid1.CellRect(1,1));
    end;
      

  4.   

    with Sender as TstringGrid do
    begin
      Canvas.Brush.Style := bsSolid;
      if ((Sender as TStringGrid).Cells[ACol][ARow] = 'a') then
        Canvas.Brush.Color := clyellow
      else
        Canvas.Brush.Color := clRed;
      Canvas.FillRect(stringgrid1.CellRect(ACol,ARow));
    end;   
      

  5.   

    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      with StringGrid1 do
      begin
        if (ARow <= FixedRows - 1) or (ACol <= FixedCols - 1) then
          Canvas.Brush.Color := clBtnface
        else 
        //根据不是的条件设置不同的颜色
          Canvas.Brush.Color := ;
        Canvas.FillRect(Rect);
      end;
    end;