unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, DBCtrls, StdCtrls, Grids, DBGrids, DB, ADODB, ComCtrls;type TForm1 = class(TForm) ADOConnection1: TADOConnection; ADOQuery1: TADOQuery; DataSource1: TDataSource; DBGrid1: TDBGrid; Memo1: TMemo; DBNavigator1: TDBNavigator; Bevel1: TBevel; Button1: TButton; Bevel2: TBevel; DateTimePicker1: TDateTimePicker; procedure Button1Click(Sender: TObject); procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);beginadoquery1.Close;adoquery1.SQL:=memo1.Lines;adoquery1.Open;end;procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);beginif field.DataType=ftDateTime then begin DateTimePicker1.DateTime:=field.AsDateTime; if gdSelected in State then begin DateTimePicker1.Left:=TDBGrid(Sender).Left+rect.left+1; DateTimePicker1.top:=TDBGrid(Sender).top+rect.top+1; DateTimePicker1.Width:=rect.Right-rect.left+3; DateTimePicker1.Height:=rect.Bottom-rect.Top+3; DateTimePicker1.Visible:=true; end else begin DateTimePicker1.Visible:=false; end; end;end;end.要DEMO就加我QQ:3860040!顺便支持下我的绿色SQL www.suisoft.cn 谢谢了!