unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, PublicUnit, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
DBGrid1: TDBGrid;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
PrintDBGrid(DBGrid1, 'adfdf');
end;
end.
///////////////////////////////////////////////////
unit PublicUnit;
// 文件名要用 Unit 名相同
interface
uses
Grids, DBGrids, // 这两个是 DBGrid用到的单元
Dialogs;
// ShowMessage ,这里用到 ShowMessage 可以删除它
procedure PrintDBGrid(DBGrid: TDBGrid;
pTitle: string);
implementation
procedure PrintDBGrid(DBGrid: TDBGrid;
pTitle: string);
begin
ShowMessage(pTitle);
end;
end.