|
-
Jan 11th, 2008, 07:07 AM
#1
Thread Starter
New Member
Customize DateTimePicker
Hi,
I'm trying to customize a DateTimePicker to "dd-MM-yyyy" and not "dd/MM/yyyy", wich is the actual format. I used the following code, that didn't work:
Code:
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "dd-MM-yyyy "
Does anyone knows how can i overcome this problem?
Thanks
-
Jan 11th, 2008, 07:33 AM
#2
Hyperactive Member
Re: Customize DateTimePicker
1. Set the DateTimePicker's Format property to DateTimePickerFormat.Custom.
2. Set the DateTimePicker's CustomFormat to the string above.
(you can do step 1 in the designer)
WHY THE HELL DON'T I READ THE QUESTION BEFORE I POST???!!!!
The answer to your question is that the string format is incorrect. You must use uppercase `M`s: "dd-MM-yy"
OKAY! THIS IS GETTING SILLY...
I DON'T KNOW WHY YOUR EFFTING CODE WON'T WORK, AND I'M NOT SURE I EFFTING CARE ! (I'm off to get my head/eyesight examined!!!)
Last edited by bigMeUp; Jan 11th, 2008 at 07:40 AM.
-
Jan 11th, 2008, 07:33 AM
#3
Re: Customize DateTimePicker
I tried this today
Code:
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "dd-MM-yy "
and it displayed 11-01-08
and then this
Code:
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "dd-MMM-yy "
and it displayed 11-Jan-08
BTW - I tried 2 digit and 4 digit years and the results were as expected.
Last edited by dbasnett; Jan 11th, 2008 at 07:38 AM.
-
Jan 11th, 2008, 07:35 AM
#4
Re: Customize DateTimePicker
 Originally Posted by bigMeUp
1. Set the DateTimePicker's Format property to DateTimePickerFormat.Custom.
2. Set the DateTimePicker's CustomFormat to the string above.
(you can do step 1 in the designer)
1. He did "DateTimePicker1.Format = DateTimePickerFormat.Custom" from his original post
-
Jan 11th, 2008, 07:50 AM
#5
Hyperactive Member
Re: Customize DateTimePicker
dbasnett: Allow me, kind sir, to refer you to my edits!
-
Jan 11th, 2008, 08:02 AM
#6
Re: Customize DateTimePicker
I do that also, matter of fact I missed that they had set format to custom the first time I read it, but caught myself before I posted. My excuse is that I am not as young as I used to be. Your edits made me 
I copied / pasted the code from the original post and it worked. So "Does anyone knows how can i overcome this problem?" is no, I think, because we don't knows what the problem is.
-
Jan 11th, 2008, 08:41 AM
#7
Thread Starter
New Member
Re: Customize DateTimePicker
Thank you all!
So, the conclusion is that you don't know why is this hapening, because the code is correct, wright?
So,...i don't know how to overcome this....
Thanks both
-
Jan 11th, 2008, 09:36 AM
#8
Re: Customize DateTimePicker
Try
vb.net Code:
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
MessageBox.Show(DateTimePicker1.Value.ToString("dd-MM-yyyy"))
End Sub
-
Jan 11th, 2008, 10:53 AM
#9
Re: Customize DateTimePicker
When you say "it didn't work", what exactly does it do and what is the expected result?
-
Jan 11th, 2008, 11:09 AM
#10
Re: Customize DateTimePicker
 Originally Posted by mqdias
Thank you all!
So, the conclusion is that you don't know why is this hapening, because the code is correct, wright?
So,...i don't know how to overcome this....
Thanks both
WE don't know what IS happening.
It is hard to diagnose "I used the following code, that didn't work" and "Does anyone knows how can i overcome this problem?"
-
Jan 11th, 2008, 11:12 AM
#11
Re: Customize DateTimePicker
This is actually resolved. He also posted the same question on another JM Forum.
He had code that interacted with an application called AutoDesk, and that was causing problems with his VB code. He moved his VB code above the code that interacts with this application, and everything worked for him.
@mgdias: you could help us out by pulling down the Thread Tools menu and clicking the Mark Thread Resolved menu item. That will let everyone know that you have your answer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|