代码如下:(以下显的是性别信息)
clientDataSet1.open;
ClientDataSet1.First;
   while not (ClientDataSet1.Eof) do
   begin
     case ClientDataSet1.FieldByName('Sex').Value of
     0:StringGrid1.Cells[1, ClientDataSet1.FieldValues['sex']] := '未知';
     1:StringGrid1.Cells[1, ClientDataSet1.FieldValues['sex']] := '女';
     2:StringGrid1.Cells[1, ClientDataSet1.FieldValues['sex']] := '男';
     end;
     ClientDataSet1.Next;
   end;why????

解决方案 »

  1.   

    clientDataSet1.open;
    ClientDataSet1.First;
    i:=1
       while not (ClientDataSet1.Eof) do
       begin
        case ClientDataSet1.FieldByName('Sex').asinteger of
         0:StringGrid1.Cells[i, ClientDataSet1.FieldValues['sex']] := '未知';
         1:StringGrid1.Cells[i, ClientDataSet1.FieldValues['sex']] := '女';
         2:StringGrid1.Cells[i, ClientDataSet1.FieldValues['sex']] := '男';
         end;
         ClientDataSet1.Next;
    i:=i+1
       end;
      

  2.   

    可以的,我做数据显示,经常用TStringGrid来显示:虽然麻烦一点,但很安全!
      

  3.   

    Rcol := 1 ;
    query_new.First;
    While not query_new.Eof Do
    begin
         stringGrid1.Cells[0,Rcol]:= query_new.FieldByName('单位名称').asstring;
         stringGrid1.Cells[1,Rcol]:= query_new.FieldByName('摊位号').asstring;
         stringGrid1.Cells[2,Rcol]:= query_new.FieldByName('主营产品').asstring;
         stringGrid1.Cells[3,Rcol]:= query_new.FieldByName('法人').asstring;
         stringGrid1.Cells[4,Rcol]:= query_new.FieldByName('起租时间').asstring;
         //stringGrid1.Cells[5,Rcol]:= query_new.FieldByName('退租时间').asstring;
         inc(Rcol);
         query_new.Next;
    end;