Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Suite Pro
  New Posts New Posts RSS Feed - Datetime Picker - empty date ?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Datetime Picker - empty date ?

 Post Reply Post Reply
Author
Message
stuc View Drop Down
Groupie
Groupie


Joined: 05 May 2011
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote stuc Quote  Post ReplyReply Direct Link To This Post Topic: Datetime Picker - empty date ?
    Posted: 12 August 2011 at 9:16am


I'd like to use the datetimepicker as a data entry field but the users must be able to leave the date empty?

Can this be done ?


Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 13 August 2011 at 2:19am
Yes it can, use the Custom setting that way you can then set the date field as blank. I am not in the office so can't post a code snippet, however if nobody else does I will post it on Monday morning.
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 13 August 2011 at 2:27am
Hi,

I found a piece of code I had posted a while back in the Controls forum on this.

Private Sub Form_Load()
    With dtpDateOfRequest
        .Value = Format$(Date, "dd/mm/yyyy")
        .Format = xtpPickerCustom
        .CustomFormat = " "
    End With
End Sub

Private Sub dtpDateOfRequest_CloseUp()
    dtpDateOfRequest.Format = xtpPickerShortDate
End Sub
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
stuc View Drop Down
Groupie
Groupie


Joined: 05 May 2011
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote stuc Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2011 at 4:07am

Thanks fo rthe reply.  This works ok for when the field is first on the screen but I cant trap the delete key for when the user wants to delete the date.

I dont really want to have to put a "delete" button on screen to clear the field.


Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2011 at 4:21am
Hi stuc,

Yeah I know about the lack of the keydown, keypress & keyup on the DateTimePicker. I rarely use it due to the way it skins (you can't see the day text clearly in some instances). However as a workaround why don't you try this:

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Const VK_DELETE = &H2E

Private Sub Form_Load()
    With DateTimePicker
        .Value = Format$(Date, "dd/mm/yyyy")
        .Format = xtpPickerCustom
        .CustomFormat = " "
    End With
End Sub

Private Sub DateTimePicker_CloseUp()
    DateTimePicker.Format = xtpPickerShortDate
End Sub

Private Sub Timer_Timer()
    If CBool(GetAsyncKeyState(VK_DELETE)) Then
        With DateTimePicker
            .Value = Format$(Date, "dd/mm/yyyy")
            .Format = xtpPickerCustom
            .CustomFormat = " "
        End With
    End If
End Sub


Set the timer to be 100 milliseconds, it's crude but works well.
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
stuc View Drop Down
Groupie
Groupie


Joined: 05 May 2011
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote stuc Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2011 at 4:32am

Thanks, that works but im using it in a form that has several instances of it plus a host of other controls.

I'll fallback to my usual date picker I think.


Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2011 at 5:21am
Yeah I can understand why you will be best falling back to your usual date picker.

Personally I use the DTPicker from the "Microsoft Windows Common Controls-2 6.0 (SP6)" for the reasons I said above, which can be seen in my other post: http://forum.codejock.com/forum_posts.asp?TID=17827
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition
Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6)
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.