我做一个关于tstringgrid组件的实力但就是编译通不过,问题很多
  如:var   
      tstringgrid,colcout,rowcount,cell,等说没有定义
  怎么回是啊?unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;type
    TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
   var
      i,j:integer;
   begin       with StringGrid1 do
        for i:=0 to colcount-1 do
            cell[i,0]:='第'+inttostr(i)+'列';
       with stinggrid1  do
        for j:=1 to  rowcount-1 do
             cell[0,j]:='第'+inttostr(j)+'行';
   end;
end;end.program Project1;uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};{$R *.res}begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.[Error] Unit1.pas(29): Statement expected but 'VAR' found
[Error] Unit1.pas(33): Undeclared identifier: 'StringGrid1'
[Error] Unit1.pas(34): Undeclared identifier: 'colcount'
[Error] Unit1.pas(35): Undeclared identifier: 'cell'
[Error] Unit1.pas(36): Undeclared identifier: 'stinggrid1'
[Error] Unit1.pas(37): Undeclared identifier: 'rowcount'
[Error] Unit1.pas(39): '.' expected but ';' found
[Warning] Unit1.pas(40): Text after final 'END.' - ignored by compiler
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

解决方案 »

  1.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
       var
          i,j:integer;
       begin       with StringGrid1 do
            for i:=0 to colcount-1 do
                cell[i,0]:='第'+inttostr(i)+'列';
           with stinggrid1  do
            for j:=1 to  rowcount-1 do
                 cell[0,j]:='第'+inttostr(j)+'行';
       end;
    end;
    写错啦 var怎么在begin下面 改成下面的procedure TForm1.FormCreate(Sender: TObject);
       var
          i,j:integer;
       begin       with StringGrid1 do
            for i:=0 to colcount-1 do
                cell[i,0]:='第'+inttostr(i)+'列';
           with stinggrid1  do
            for j:=1 to  rowcount-1 do
                 cell[0,j]:='第'+inttostr(j)+'行';
       end;
      

  2.   

    我后来改了 也不行 
     经过思考,
    procedure TForm1.FormCreate(Sender: TObject);
       var
          i,j:integer;
       begin       with StringGrid1 do
            for i:=0 to colcount-1 do
                CELLS[i,0]:='第'+inttostr(i)+'列';
           with stringgrid1  do
            for j:=1 to  rowcount-1 do
                 CELS[0,j]:='第'+inttostr(j)+'行';
       end;