StringGrid 怎样使某行处于选中状态?怎样隔行换色?
能给出具体操作步骤或代码吗?

解决方案 »

  1.   

    选中一行,把Option下goRowSelected设为True就可以了
      

  2.   

    隔行换色procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      with StringGrid1 do
      begin
          if ARow mod 2 = 0 then
            begin
              Canvas.Brush.Color := RGB(255,255,255);
              Canvas.Font.Color:=clGreen;
            end
          else
            begin
              Canvas.Brush.Color := clInfoBK;
              Canvas.Font.Color:=clRed;
            end;
           Canvas.FillRect(Rect);
           Canvas.TextOut(Rect.Left + 2,Rect.Top + 2, Cells[ACol,ARow]);
      end;
    end;
      

  3.   

    goRowSelected=True
    已经开启了,单击时整行处于选中状态
    我想实现的是指定行选中,例如第3行选中
      

  4.   


    goRowSelected := True;
    然后StringGrid1.Row := i; //i为你要选中的行
    即可