我错误的地方的注释本来是一行的,发出来变成了两行。
错误在语句
FSourceQuery.Assign(Value); 
错误信息为
[Error] MDStringGrid.pas(83): Undeclared identifier: 'FSourceQuery'

解决方案 »

  1.   

    SetSourceQuery前面要加TMDStringGrid吧?
      

  2.   

    现在还有问题
    我把控件加入FORM的时候,报错
    错误信息的意思是:不能打开一个关闭的DATESET
    我现在的目的是想做成象DbGrid的样子
    是否我的参数里面不能直接用Query,而是要使用DateSource
      

  3.   

    错误信息是Cannot perform this operation on a close dateset
      

  4.   

    能告诉我怎么查看别的控件的VCL源代码吗
    我想参考一下DbGrid的做法
      

  5.   

    我觉得你还有一个单元需要引用的而你却没用:
    uses db;
      

  6.   

    SetSourceQuery 你是申明在TMDStringGrid,所以定义的时候要写成
    procedure TMDStringGrid.SetSourceQuery (Value:TQuery);Cannot perform this operation on a close dateset的意思是你在对使用
    dataset前要先openVCL源代码在delphi安装目录下的source\vcl中有
      

  7.   

    谢谢各位的回复,修改中
    将procedure SetSourceQuery (Value:TQuery);
    改成了procedure TMDStringGrid.SetSourceQuery (Value:TQuery);
    然后在ColCount:=FSourceQuery.FieldCount;
      RowCount:=FSourceQuery.RecordCount+1;
      for i:=0 to ColCount-1 do
        cells[0,i]:=FSourceQuery.Fields[i].DisplayName;
      if FSourceQuery.RecordCount >0 then
      begin
        FSourceQuery.First;
        i:=1;
        while (i <= RowCount-1) and (not FSourceQuery.Eof) do
        begin
          for j:=0 to ColCount-1 do cells[i,j]:=FSourceQuery.Fields[j].AsString;
          FSourceQuery.Next;
          i:=i+1;
        end;
    前面加了一个判断if FSourceQuery.Active then 
    begin
    ...
    ...
    end;   现在控件能加进去了
    但是我还有一个问题,我想在创建StringGrid 的时候同时还创建按钮
    FAddButton
    但是我这样写
    FAddButton:=TButton.Create(Parent);却实现不了
    请再帮我看看好吗,分不够我还可以加
      

  8.   

    FAddButton:=TButton.Create(AOwner);
    FAddButton.Parent:=Self;
    这样可以吗?
      

  9.   

    浪人西林,照你那样说的,可以,但是还是有问题
    那个Button只能放在StringGrid所在的区域里面
    我想让他能够出现在Form里面,而不是限定在StringGrid里面。
    我将FAddButton.Parent:=Self改成FAddButton.Parent:=Parent却不能显示我的这个Button了
    能再帮我看看吗,谢谢