unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
ADOTable1: TADOTable;
DBGrid1: TDBGrid;
Button1: TButton;
procedure DBGrid1DblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
// var
DataSet : TDataSet
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.DBGrid1DblClick(Sender: TObject);
//var
//DataSet : TDataSet
begin
DataSet := DBGrid1.DataSource.DataSet;
with TForm2.Create(nil) do begin
edit1.text :=DataSet.FieldByName(‘客户‘).Asstring;
ShowModal;
Free;
end;
end;
end.
连上面
procedure TForm2.Button1Click(Sender: TObject);begin with adoquery1 dobeginclose;sql.clear;sql.add(‘select * from 销售表 where 客户=‘‘‘+trim(edit1.text)+‘‘‘‘);open;end;end;