我在TStringGrid1.rowcount:=25赋值时出现访问冲突的问题,很奇怪,当我将TStringGrid1.rowcount赋值小于14
时没问题,但当大于14时就出现访问冲突的问题,我看了下 TSringGrid 的属性中好像没设置行数限制的属性啊。。
请高手指教指教,谢谢

解决方案 »

  1.   

    procedure TForm_station.FormShow(Sender: TObject);
    var sqlstr:string;
        i:integer;
        currhostid:string;
    begin
       combobox1.Items.Clear;
       sqlstr:='..........';//省略
       form_struectree.querymessage(dbfrm.Query1,sqlstr);
       if dbfrm.Query1.RecordCount<1 then exit;
       dbfrm.Query1.First;
       i:=0;
       listbox1.Items.Clear;
       while not dbfrm.Query1.Eof do
       begin
           combobox1.Items.Add(dbfrm.Query1.fieldbyname('type_name').AsString);
           stationtype[i]:=dbfrm.Query1.fieldbyname('station').AsInteger;
           listbox1.Items.Add(inttostr(dbfrm.query1.fieldbyname('station').asinteger));
           dbfrm.Query1.Next;
           i:=i+1;
       end;
       sqlstr:='select host_name,hostid,status from sfis1.c_host_name_t where 
       form_struectree.querymessage(dbfrm.Query1,sqlstr);
       if dbfrm.Query1.RecordCount<1 then exit
       currhost:=inttostr(dbfrm.Query1.fieldbyname('host').AsInteger);   sqlstr:='。';
       form_struectree.querymessage(dbfrm.Query1,sqlstr);//执行SQL语句
       stringgrid1.RowCount:=dbfrm.Query1.RecordCount+1;//就是这里,当dbfrm.Query1.RecordCount
    数量不大时不会报错,一超过14就开始报错,这是一个窗体打开的代码,而且没有ONCREAT(),请指教
      

  2.   

    你直接改成stringgrid1.RowCount:=15;还会错吗,如果错注释掉formshow,只把这一行写道formcreate还会错吗
      

  3.   

    直接写成 stringgrid1.RowCount:=15 也是会报错,写成 stringgrid1.RowCount:=10这样小点的数就没事
      

  4.   

    是这句了,我用调试,每次到这里就停住报错啦。。我看了很多关于 Access Violation 的现象及原因,都好像没适合我这种情况的,所以很烦,不知怎么解决,,还请高手指点指点