我在一个窗口中使用StingGrid,但由于数据太多(10*5),而且演示的时候需要改变部分数据,我不想在每次运行时都输入一遍,请问如何在设计就对表格输入数据呢? 
不会用下面这种方法吧?
StringGrid1.Cells[1,1]:=
StringGrid1.Cells[2,1]:=
......
StringGrid1.Cells[10,1]:=
StringGrid1.Cells[1,2]:=
StringGrid1.Cells[2,2]:=
......
StringGrid1.Cells[10,2]:=
......
StringGrid1.Cells[9,5]:=
StringGrid1.Cells[10,5]:=
能不能像edit那样设计时在窗口直接赋值?或像一维数组那样(23,27,31,24,27,31,30,36,39,30,36,39,50,9999,9999)?

解决方案 »

  1.   

    用随机数还要手工输入吗?
    例如:
    StringGrid1.Cells[1,1]:= 23;
    StringGrid1.Cells[2,1]:= 27;
    StringGrid1.Cells[3,1]:= 24;
    StringGrid1.Cells[4,1]:= 27;
    StringGrid1.Cells[5,1]:= 30;
    StringGrid1.Cells[6,1]:= 36;
    StringGrid1.Cells[7,1]:= 30;
    StringGrid1.Cells[8,1]:= 36;
    StringGrid1.Cells[9,1]:= 50;
    StringGrid1.Cells[10,1]:=9999;
    能不能用(23,27,24,27,30,36,30,36,50,9999)数组的方式或设计时在窗体StringGrid1中设好初始值。
    这些数小部分在运行时会手工输入改变!  
      

  2.   

    const
      data :array[0..1,0..1] of integer=
      ( (1,2),(3,4));var
      i,j:integer;with stringgrid1 do
    begin
      rowcount := length(data);
      colcount := length(data[0]);
      for i:=0 to High(data) do
      for j:=0 to High(Data[0]) do
        cells[j,i] := inttostr(data[i][j]);
    end;
      

  3.   

    多谢shuihan20e 、windindance的方法,问题解决了。