Check out the code in this unit
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
Grids, ComCtrls, StdCtrls, DatePicker;
type
{ TForm1 }
TForm1 = class(TForm)
btnTrans: TButton;
btnCat: TButton;
cbCat: TComboBox;
cbTrans: TComboBox;
dpCal: TDatePicker;
ilTitle: TImageList;
lblTrans: TLabel;
lblCat: TLabel;
memTrans: TMemo;
memCat: TMemo;
sgTrans: TStringGrid;
procedure btnCatClick(Sender: TObject);
procedure btnTransClick(Sender: TObject);
procedure sgTransSelectEditor(Sender: TObject; aCol, aRow: Integer;
var Editor: TWinControl);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.sgTransSelectEditor(Sender: TObject; aCol, aRow: Integer;
var Editor: TWinControl);
begin
if (aCol=0) and (aRow >0) then
begin
dpCal.BoundsRect := sgTrans.CellRect(aCol,aRow);
sgTrans.Cells[sgTrans.Col, sgTrans.Row] :=DateToStr(dpCal.TheDate) ;
Editor := dpCal;
end;
if (aCol=1) and (aRow >0) then
begin
cbTrans.BoundsRect := sgTrans.CellRect(aCol,aRow);
sgTrans.Cells[sgTrans.Col, sgTrans.Row]:=cbTrans.Text;
Editor := cbTrans;
end;
if (aCol=2) and (aRow >0) then
begin
cbCat.BoundsRect := sgTrans.CellRect(aCol,aRow);
sgTrans.Cells[sgTrans.Col, sgTrans.Row]:=cbCat.Text;
Editor := cbCat;
end;
end;
procedure TForm1.btnTransClick(Sender: TObject);
begin
cbTrans.Items := memTrans.Lines;
end;
procedure TForm1.btnCatClick(Sender: TObject);
begin
cbCat.Items := memCat.Lines;
end;
initialization
{$I Unit1.lrs}
end.
I used the DatePicker Component for the date editor
Regards
Dave