Print Page | Close Window

[SOLVED] DateTimePicker Display Bug!?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=17154
Printed Date: 23 May 2024 at 2:19am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED] DateTimePicker Display Bug!?
Posted By: Xander75
Subject: [SOLVED] DateTimePicker Display Bug!?
Date Posted: 25 August 2010 at 4:57am
Hi,

I am using several DateTimePicker controls on a form and my requirement initally is to have these blank so the user must enter a date. I have done this using the following code in the Form Load event:


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

So far so good, the control is blank and all seems fine... until I try and select a date, without setting the CustomFormat to "dd/mm/yyyy" I get no date appearing in the control so using the following code I get the date to appear, however the date displays as "25/00/2010":


Private Sub dtpDateOfRequest_Change()
    Debug.Print dtpDateOfRequest.Value
    dtpDateOfRequest.CustomFormat = "dd/mm/yyyy"
    Debug.Print dtpDateOfRequest.Value
End Sub

The Debug.Print lines cleary print the date as "25/08/2010" but the control displays "25/00/2010", is this a bug or am I doing something wrong?

Thanks...




-------------
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)



Replies:
Posted By: Xander75
Date Posted: 25 August 2010 at 5:21am
Hi,

I have resolved my issue however I am not sure if the above mentioned is a bug or not as the month in CustomFormat "dd/mm/yyyy" is displaying as "00" so I will leave this open for now...

I managed to make the DateTimePicker display as blank and then display the correct date on change by using the following code:


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)


Posted By: Hemesh
Date Posted: 27 August 2010 at 11:19am
maybe try dd/MM/yyyy instead of dd/mm/yyyy?

-------------
Product: Xtreme SuitePro (ActiveX) version 18.5.0

Platform: Windows 7 Enterprise (64-bit)

Language: Visual Basic 6.0


Posted By: Xander75
Date Posted: 30 August 2010 at 3:24am
Hemesh,
 
Thanks for that, this has resolved the issue I was having.


-------------
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)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net