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!!!)
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.
Re: Customize DateTimePicker
Quote:
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
Re: Customize DateTimePicker
dbasnett: Allow me, kind sir, to refer you to my edits!
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.
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
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
Re: Customize DateTimePicker
When you say "it didn't work", what exactly does it do and what is the expected result?
Re: Customize DateTimePicker
Quote:
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?"
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.