可以,代码如下(已经运行成功)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls;
type
TForm1 = class(TForm)
Table1: TTable;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.Show;
Form2.GetDataSet(Table1);
end;
end.
//-------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB;
type
TForm2 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
private
{ Private declarations }
public
procedure GetDataSet(DS: TDataSet);
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TForm2 }
procedure TForm2.GetDataSet(DS: TDataSet);
begin
DataSource1.DataSet := Ds
end;
end.