默认的lazarus DBGrid选择Datetime类型时是没有下拉选择日期的,按以下方法就能实现下拉选择日期。
在界面放一个DBDateTimePicker控件,并设置控件的Visibler为false,在DBGrid的DBGrid1SelectEditor添加下面的代码就可以。
procedure TForm1.DBGrid1SelectEditor(Sender: TObject; Column: TColumn; var Editor: TWinControl); begin if DBGrid1.SelectedField.DataType=ftDateTime then begin DBDateTimePicker1.DataSource:=DBGrid1.DataSource; DBDateTimePicker1.DataField:=DBGrid1.SelectedField.FieldName; DBDateTimePicker1.boundsRect:=DBGrid1.SelectedFieldRect; Editor:=DBDateTimePicker1; end; end;
标签:DBGrid,DBGrid1,DBDateTimePicker1,Datetime,日期,lazarus From: https://www.cnblogs.com/qiufeng2014/p/17645090.html