Witam, tworzę projekt w którym znajduje się StringGrid i chciałbym, by w kolumnie nr.3 wyświetlał się ComboBox, a w nr.4 DateTimePicker (po kliknięciu na nie).
Z pierwszym sobie poradziłem z pomocą tej strony.
Jednak postępując analogicznie z drugim (DateTimePicker-em), nie udaje mi się osiągnąć zamierzonego efektu i otrzymuję błąd 'access violation at...' przy kliknięciu na komórkę z kolumny nr.4.
Będę wdzięczny za wszelkie podpowiedzi.
Kod wykorzystywanych procedur:
procedure tform1.movedater(sender: TObject);
var rect:trect;gwidth:integer;
begin
rect:=stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row);
gwidth:=stringgrid1.GridLineWidth;
panel:=tpanel.Create(Form1);
with panel do
begin
parent:=stringgrid1;
visible:=true;
bevelouter:=bvnone;
ctl3d:=false;
parentbackground:=false;
parentcolor:=false;
color:=clWhite;
caption:='';
top:=rect.Top+gwidth;
left:=rect.Left+gwidth;
height:=(rect.Bottom-rect.Top)+1;
width:=(rect.Left-rect.Right)+1;
end;
dator:=tdatetimepicker.Create(Form1);
with dator do
begin
parent:=panel;
left:=0;
top:=0;
width:=mypanel.Width;
height:=mypanel.Height;
datemode:=dmcombobox;
kind:=dtkDate;
mindate:=strtodate('1947-01-01');
maxdate:=now;
OnChange:=datorchange;
end;
end;
procedure tform1.datorchange(sender: TObject);
begin
stringgrid1.Cells[stringgrid1.Col,stringgrid1.Row]:=datetostr(dator.DateTime);
panel.Visible:=false;
end;
procedure TForm1.StringGrid1Click(Sender: TObject);
begin
if stringgrid1.Col=2 then
begin
moveeditor(sender);
myeditor.DroppedDown:=true;
end
else
begin
if stringgrid1.Col=3 then
begin
movedater(sender);
end;
end;
end;