Page 1 of 1

DateTime Picker

Posted: Thu Jan 11, 2007 6:13 am
by behdad
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.

Posted: Thu Jan 11, 2007 9:00 pm
by webops
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

Posted: Fri Jan 12, 2007 12:35 am
by behdad
Hi Gabor,

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

Cheers,
Behdad.