CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Posts
    6

    Transferring keyboard control to the calendar in the datepicker control

    I ve to select a date from the datepicker controls calender without using the mouse.How can i add a code which uses the key events to transfer the control to the calendar and thereafter i can use the updown arrows for selecting a particular date..Please let me know if anybody know a solution ,,thankyu

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    DtPicker...

    Is already able to show calendar by keystroke.
    You have to press alt key + arrow down to show the calendar.
    If you have other controls on form, you can switch focus using the Tab button.
    If you need to set the focus to calendar via code, you can code where needed:
    DTPicker1.SetFocus

    If you want to code so that pressing a key, datepicker show calendar, you can code this way:
    Press F3 to test this code
    Code:
    Option Explicit
    'set form property "keypreview" to true at deisgn time!
    Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If (KeyCode And vbKeyF3) Then
        DTPicker1.SetFocus
        SendKeys "%{DOWN}", True
    End If
    
    End Sub
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Nov 2002
    Posts
    6
    That will work in a normal dtpicker control, but i m calling the datepickers calendar using API calls, I m able to show the calendar on keypresses,but the focus not comes to the calender only on any keypress even i tried to catch keypresses and set the focus.I ve to click on the calendar inorder to move the dates using the arrow keys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured