DateTime Picker

Class library usage, coding and language questions.
behdad
Posts: 16
Joined: Wed Nov 22, 2006 10:56 pm
Location: Australia

DateTime Picker

Post by behdad » Thu Jan 11, 2007 6:13 am

Hi,

I am having some difficulty to set and get date on a control which seems to be of type SysDateTimePick32. Unfortunately when I create an object of type DateTimePicker using this control's handle, then I can't just set its text to the value I want. How do I do that. The control looks like the one in the following page at the top which is showing the value 6/16/70:


http://www.codeguru.com/cpp/controls/co ... php/c2229/

Thank you for your help.

Cheers,
Behdad.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Thu Jan 11, 2007 9:00 pm

You can read the datetime value of the control with the element value property as follows:

Code: Select all

dtControl = form.FindClassName("SysDateTimePick32");
Element dtElement = dtControl.Element.FindChild(Role.DropList);
Console.WriteLine("Time-String: " + dtElement.Value);
Unfortunately you cannot set the datetime value on the same way, but you can use the sendkey function (e.g. 11.01.2007):

Code: Select all

dtControl.Focus();
dtControl.SendKeys("11{RIGHT}01{RIGHT}2007");
Gabor Herget
Ranorex Team

behdad
Posts: 16
Joined: Wed Nov 22, 2006 10:56 pm
Location: Australia

Post by behdad » Fri Jan 12, 2007 12:35 am

Hi Gabor,

Thank you. I was more interested in setting and it did work.

Cheers,
Behdad.