PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Date Time Picker

Reply

Date Time Picker

 
Thread Tools Rate Thread
Old 04-12-2006, 10:37 PM   #1
Chris Oswald
Guest
 
Posts: n/a
Default Date Time Picker


Is it possible to change the initial focus on the DateTimePicker
control. For instance, if I have month, day, and year, can I default
the focus to the year. I don't see any methods that allow me to to do
this. I'm betting I will have to do a custom control, but hopefully
not. I'm running NETCF 2.0.

  Reply With Quote
Old 05-12-2006, 08:15 AM   #2
Buthrakaur
Guest
 
Posts: n/a
Default Re: Date Time Picker

The only solution I can see at the moment is to trap the GetFocus event
and send right-arrow keystroke twice to move the cursor to the year
field...

Chris Oswald napsal:
> Is it possible to change the initial focus on the DateTimePicker
> control. For instance, if I have month, day, and year, can I default
> the focus to the year. I don't see any methods that allow me to to do
> this. I'm betting I will have to do a custom control, but hopefully
> not. I'm running NETCF 2.0.


  Reply With Quote
Old 05-12-2006, 02:32 PM   #3
Chris Oswald
Guest
 
Posts: n/a
Default Re: Date Time Picker

That's a good idea! Thanks for thinking outside the box. I still have
a few issues to figure out if there are multiple DTPs on a form.

If there are, I only want to reselect if they tab to the DTP or if it's
the first item to get focus. Otherwise, if the user selects the month
day or year i don't want to override what they have selected.


Buthrakaur wrote:
> The only solution I can see at the moment is to trap the GetFocus event
> and send right-arrow keystroke twice to move the cursor to the year
> field...
>
> Chris Oswald napsal:
> > Is it possible to change the initial focus on the DateTimePicker
> > control. For instance, if I have month, day, and year, can I default
> > the focus to the year. I don't see any methods that allow me to to do
> > this. I'm betting I will have to do a custom control, but hopefully
> > not. I'm running NETCF 2.0.


  Reply With Quote
Old 05-12-2006, 02:45 PM   #4
Buthrakaur
Guest
 
Posts: n/a
Default Re: Date Time Picker

I don't fully understand what you exacly need, but I thing this
GetFocus-method can do anything you want - you just have to specify the
condition for programatic cursor repositioning when DTP gets focused...

DTP1.Getfocus += new EventHandler(MyDTPHandler);
....
DTP99.Getfocus += new EventHandler(MyDTPHandler);
....
private void MyDTPHandler(object sender, EventArgs e)
{
if (sender == DTP123 || some_other_condition)
{
IntPtr hwnd = (sender as Control).Handle;
Win32Window.SendMessage(hwnd, (int)WM.KEYDOWN, (int)Keys.Right,
0);
Win32Window.SendMessage(hwnd, (int)WM.KEYUP, (int)Keys.Right, 0);
Win32Window.SendMessage(hwnd, (int)WM.KEYDOWN, (int)Keys.Right,
0);
Win32Window.SendMessage(hwnd, (int)WM.KEYUP, (int)Keys.Right, 0);

}
}

Chris Oswald napsal:
> That's a good idea! Thanks for thinking outside the box. I still have
> a few issues to figure out if there are multiple DTPs on a form.
>
> If there are, I only want to reselect if they tab to the DTP or if it's
> the first item to get focus. Otherwise, if the user selects the month
> day or year i don't want to override what they have selected.
>
>
> Buthrakaur wrote:
> > The only solution I can see at the moment is to trap the GetFocus event
> > and send right-arrow keystroke twice to move the cursor to the year
> > field...
> >
> > Chris Oswald napsal:
> > > Is it possible to change the initial focus on the DateTimePicker
> > > control. For instance, if I have month, day, and year, can I default
> > > the focus to the year. I don't see any methods that allow me to to do
> > > this. I'm betting I will have to do a custom control, but hopefully
> > > not. I'm running NETCF 2.0.


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off