请问将stringgrid的第2行第1列设置为红色该如何做,请给一些代码

解决方案 »

  1.   

    procedure TForm1.DrawGrid1DrawCell(Sender: TObject; Col, Row: Longint; Rect: TRect; State: TGridDrawState); 
    var 
      index: integer; 
    begin 
      index := Row * DrawGrid1.ColCount + Col; 
      with Sender as TDrawGrid do 
      begin 
        Canvas.Brush.Color := clBackGround; 
        Canvas.FillRect(Rect); 
        ImageList1.Draw(Canvas,Rect.Left,Rect.Top,index); 
        if gdFocused in State then 
          Canvas.DrawFocusRect(Rect); 
      end; 
    end;