I am using the following routine to show a TDateTimePicker component on a
Date field in a DBGrid. It works but it has a quirk which makes it
unusable.
When the user gets into the cell, a comboBox is shown and he can click on
it
to choose the date in the Calendar; but as soon as the date is chosen and
gets into the cell, the combo box cannot be shown anymore.
What is it that I am doing wrong ?
with Sender as TDBGrid do
begin
// make sure our cell has focus
if ( gdFocused in State ) then
begin
// make sure we are on the proper column
if Column.Field.DataType = ftDate then
begin
SetWindowPos(DateTimePicker.Handle, // handle
0, // change z-order
Rect.Left + Left + 1,
Rect.Top + top + 1,
Rect.Right - Rect.Left + 2,
Rect.Bottom - Rect.top + 2,
SWP_NOZORDER or SWP_SHOWWINDOW);
// set the date in the datetimepicker to the date if the current
record
if Column.Field.IsNull then
DateTimePicker.Date := Date
else
DateTimePicker.Date := Column.Field.AsDateTime;
end;
end;


|