我是从ini文件里读数据,放到DBGrid中现实,如何做?有什么函数啊,给个例子吧,非常感谢!

解决方案 »

  1.   

    思路:delphi中一般用datasource来做为dbgrid的数据源,简单些的方法就是你不用AdoDataset连数据库,而连接本机硬盘上的物理数据源文件,ado是支持的,你把你的INI数据生成带有分隔符或固字段长的纯文件数据文件,然后用ado的连接对象来连接。
      

  2.   

    用StringGrid就可以了何必用DBGrid???
      

  3.   

    有數據源,用DBGrid,往數據源裡插數據,沒有數據源,用StringGrid,直接往單元格裡插數據。
      

  4.   

    那能给一个把一个字符串数组插入到StringGrid中的一行的例子吗?
    比如:
    name    dfsd    sdfsf    dfsdf
    name1   dfsdf   dfsdf    sdfsdf
      

  5.   

    呵呵,ClientDataSet就是专门用来处理离线的数据库的。数据更改后,再连线更新到远程数据库。
    ClientDataSet是从DataSet继承来的,当然支持DBGrid的标准操作啦。
    ADO.net就是复制的这个模式做的。
      

  6.   

    那能给一个把一个字符串数组插入到StringGrid中的一行的例子吗?
    比如:
    name    dfsd    sdfsf    dfsdf
    name1   dfsdf   dfsdf    sdfsdf--------循环写撒
      

  7.   

    with stringgrid1 do
      begin
        for i:=1 to FieldCount do
          for j;=1 to RowCount do
          begin
            stringgrid1.Cells[i,j] := ...  //读取内容
          end;
      end;
      

  8.   

    StringGrid1.ColCount := 4;
    StringGrid1.RowCount := 3; // 假设有一标头 StringGrid1.FixedRows = 1
    // 标头
    StringGrid1.Cells[0, 0] := '标头1';
    StringGrid1.Cells[1, 0] := '标头2';
    StringGrid1.Cells[2, 0] := '标头3';
    StringGrid1.Cells[3, 0] := '标头4';
    // 第一行
    StringGrid1.Cells[0, 1] := 'name';
    StringGrid1.Cells[1, 1] := 'dfsd';
    StringGrid1.Cells[2, 2] := 'sdfsf';
    StringGrid1.Cells[3, 3] := 'dsfsf';
    // 第二行
    StringGrid1.Cells[0, 2] := 'name1';
    StringGrid1.Cells[1, 2] := 'dfsd';
    StringGrid1.Cells[2, 2] := 'sdfsf';
    StringGrid1.Cells[3, 2] := 'dsfsf';
      

  9.   


    j:=1;  while not EOF do
        begin
          StringGrid1.Cells[0,j] := fieldbyname( 'name').AsString;
          StringGrid1.Cells[1,j] := fieldbyname('dfsd').AsString;
          StringGrid1.Cells[2,j] := fieldbyname('sdfsf').AsString;
          StringGrid1.Cells[3,j] := fieldbyname('dsfsf').AsString;
          StringGrid1.RowCount:=j+1;
          inc(j);
          next;
        end;
      

  10.   

    建议 
      将ini改为xml
      用ClientDataset控件
    很方便