2 Replies - 9024 Views - Last Post: 27 December 2012 - 01:33 PM Rate Topic: -----

#1 Criel  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 128
  • Joined: 11-March 11

Programatically removing datetimepicker calendar dropdown

Posted 21 December 2012 - 03:36 PM

Hi,

I've got a question regarding a datetimepicker control and if I can programatically get rid of the calendar that drops down when the user clicks the arrow button on the control.

Currently I've got my form to function if the user tabs to the date control it will pull down the calendar however when trying to code it to tab out effectively the only way I could figure out to do it is to simulate the UP arrow key being used which doesn't work too well as it puts todays date in the textbox rather than keeping it blank.

  SendKeys.Send("%{F4}")
is all I see about having this close the calendar however this doesn't seem to work on my machine - what could be the reason why this would work for everyone elses' datetimepicker control but not mine? The only way I can get it work by tabbing out is simulating the UP key.

Using .NET 3.5 VS2008 if that helps at all

Is This A Good Question/Topic? 0
  • +

Replies To: Programatically removing datetimepicker calendar dropdown

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,507
  • Joined: 16-March 11

Re: Programatically removing datetimepicker calendar dropdown

Posted 22 December 2012 - 01:13 AM

Can we see your code? That would be very helpful.

Quote

Currently I've got my form to function if the user tabs to the date control it will pull down the calendar however when trying to code it to tab out effectively the only way I could figure out to do it is to simulate the UP arrow key being used which doesn't work too well as it puts todays date in the textbox rather than keeping it blank.


Could you explain a little more what you want to happen? What do you mean by tab out effectively? What your asking changes a few ways, so I'm a little confused. Thanks.

This post has been edited by trevster344: 22 December 2012 - 09:45 AM

Was This Post Helpful? 0
  • +
  • -

#3 Criel  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 128
  • Joined: 11-March 11

Re: Programatically removing datetimepicker calendar dropdown

Posted 27 December 2012 - 01:33 PM

Surely, here is my code

Private Sub datetimepicker1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles datetimepicker1.KeyDown, datetimepicker2.KeyDown, datetimepicker3.KeyDown
    '    Dim DateDifference As Short
    '    Dim ControlArr() As DateTimePicker = {datetimepicker1, datetimepicker2, datetimepicker3}
    '    Dim fpdControl As DateTimePicker
    '    Dim DateSelected As Date
    '    Dim contTab As Boolean = False

    '    If e.KeyCode = Keys.Tab Then
    '        datetimepicker1.Focus()
    '        SendKeys.Send("%{F4}")
    '        contTab = True
    '        'Exit Sub
    '    End If

    '    For Each fpdControl In fpdControlArr
    '        DateSelected = fpdControl.Value
    '        DateDifference = DateDiff(Microsoft.VisualBasic.DateInterval.Day, Now, CDate(Trim(fpdControl.Value)))

    '        If DateDifference < 5 Then
    '            fpdControl.Format = DateTimePickerFormat.Custom
    '            fpdControl.CustomFormat = " "
    '            '  fpdControl.Text = ""
    '        End If
    '    Next
    'End Sub




What I want to happen is that if the user tabs to one of the datetimepickers the calendar drops down but I would like to add some more functionality to it and if the user tabs again once the calendar is down, it will close the calendar and move to the next control on the form. Currently, once the calendar drops down there's nothing I can try on my keyboard to close the calendar besides simulating the UP key which will put in a date which I don't want. IF the user wants to tab through the control I would like them to be able to without having the control populate a date from simulating the up key.

F4 doesn't close anything datetimepicker related - it works great for comboboxes but I'm not sure what works for the datetimepicker to close the calendar.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1