Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TSTringGrid and TDateTimePicker

Status
Not open for further replies.

tamara3776

Programmer
Apr 6, 2004
18
US
I am pretty new to delphi and am now starting on a new project. One of my first tasks is to put a date time picker inside of a cell in a string grid. So far no luck so if anyone could help it would be greatly appreciated.

Thanks in advance
 
Ok. The easiest way is also the ugliest way...

Start with throwing a TDateTimePicker on you form and set the Property Visible to false, then throw a TStringGrid on the form. Don't change any properties on the StringGrid.

Then write the following code on the OnDrawCell event:
Code:
  if (ARow = 2) and (ACol = 2) then
  begin
    DateTimePicker1.Left := StringGrid1.Left + Rect.Left+2;
    DateTimePicker1.Top := StringGrid1.Top + Rect.Top+2;
    DateTimePicker1.Width := Rect.Right - Rect.Left;
    DateTimePicker1.Height := Rect.Bottom - Rect.Top;
  end;

Then, write this code on the OnSelectCell event:
Code:
  if (ARow = 2) and (ACol = 2) then
    DateTimePicker1.Visible := true
  else
    DateTimePicker1.Visible := false;

You're done.
The next step is to catch the changes the DateTimepicker does, and write them into the StringGrid, but that is another story...


-----------------------------------------------------
-"There is always a different way to solve it"

//Nordlund
 
Thanks,
I will give it a try and let you know how it turns out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top