请问一下高手,在DElPHI里面能不能将从数据库里查出来的数据像Excel表格一样显示在界面上呀,就是有行名也有列名的那种。

解决方案 »

  1.   

    如果不用第三方控件的话,可以用TStringGrid
      

  2.   

    当然能啊,三方的数据控件都可以实现的啊。如:QuantemGrid就可以实现的,嘿嘿
      

  3.   

    用stringGrid吧,在additional属性页第四项
    下面的代码是初始化行的-----(乱码是汉字)
    procedure Tform1.SGrid_show();
    var
    i,recCount:integer;
    begin
     SGrid.Cells[0,0]:='列名1';
     SGrid.Cells[1,0]:=‘列名2';

    if q_test.recordcount>0 then
     begin
     RecCount :=q_test.recordcount;
     SGrid.RowCount := q_test.recordcount;
        for i:=1 to  q_test.recordcount do
        begin
         sgrid.cells[0,i] := intToStr(q_test.recordCount);//
    // 此处你就可以实现你要显示的行名了
         SGrid.Cells[1,i]:= q_test.fieldbyname('banzu').AsString;
          SGrid.Cells[2,i]:= q_test.fieldbyname('banci').AsString;
          ................................
          q_test.Next;
        end;
        q_test.First;end
      else
      begin
         SGrid.RowCount:=1;
      end;
         SGrid.Refresh;end;
      

  4.   

    http://www.51delphi.com/delphi/index
    这里不错,用ehlib
      

  5.   

    请问楼上的仁兄,在你的代码里面有一个q_text,这个变量是什么意思呀,我有点看不懂耶。
      

  6.   

    TStringGrid比较好,但是自己要写代码:)
      

  7.   

    我的数据是从数据库里面查出来的,如果用TStringGrid的话怎么将数据写进去呢???