[RESOLVED] [2.0] Custom DateTimePicker Format
Good morning guys. I currently have a DateTimePicker on my form with a custom format that goes like this:
Day Year Week
So.. I got the day and year down by using: dd yy
Which is the exact way he wants it. However, now week joins in. The week number is not one of the custom ones because it is.. well.. not normal. It goes something like this:
Code:
January 1st - January 7th = Week 1
January 8th - January 14th = Week 2
January 15th - January 21st = Week 3
January 22nd - January 28 = Week 4
January 29 - February 4th = Week 5
etc.. etc..
Anyways.. That goes on for the entire year.. Now, is there a way to make a new custom format class or void or override void or something or rather to do this? Like.. The function be called w for example and when you type it into the custom format box, it says it? For example:
12 06 15
That ^^ would be today for example. Thanks :)
Re: [2.0] Custom DateTimePicker Format
You're not going to be able to use a DTP. Maybe a MaskedTextBox with some validation on the numbers. There may be a third-party DTP equivalent around that could do it but I don't think the standard one will.
1 Attachment(s)
Custom DateTimePicker Format - Show Week Number
In VB6 it is possible by using the CustomFormat CallBack string.
Quote:
Originally Posted by MSDN VB6
X
A callback field. The control still uses the other valid format characters, and queries the owner to fill in the "X" portion. The owner must be ready to respond to events that request information about how to fill in these fields. Multiple 'X' characters can be used in series to signify unique callback fields.
But I can't find it in .NET DateTimePicker Reference. :(
In the attatched file, I've added a VB6 project and it's VB.NET conversion that does what you need. I hope it woun't be very hard to convert it in C#.
[Edit: Attatchment Updated]
Re: [2.0] Custom DateTimePicker Format
I couldn't convert that if my life was on the line. Besides, it has 2 dll's doesn't it? Wouldn't you have to convert them too?
Re: [2.0] Custom DateTimePicker Format
Sorry. I couldn't convert that either. :( I'm just a beginner in C#.
In VB6 it needs 'Microsoft Windows Common Conterls 6'.
I'm not sure how to run it from .NET in your system if you don't have VB6. Maybe be by installing those dlls:
http://www.microsoft.com/downloads/d...displaylang=en
http://www.microsoft.com/downloads/d...6-93AF0D8D4A1E
I've updated the attatchment and added the bin folders this time. Hope it will run this time.
Re: [2.0] Custom DateTimePicker Format
I can run it in VB no prob. I could with the last one also. It's just a matter of confiquring it with C#, which I could not do.
Re: [RESOLVED] [2.0] Custom DateTimePicker Format
Fromethius, you have marked the the thread 'resolved'.
If your problem is solved, could you please post the C# code (and the configurations you applied) ?
Thanks ! :)
Re: [RESOLVED] [2.0] Custom DateTimePicker Format
ehh.. ok..
http://www.boyet.com/Articles/Publis...Oweeknumb.html
That's pretty much it.. Also, my friend, Coniptoer recently fiqured out there was code for it developed by Microsoft but it isn't worth carrying around a dll just to do that
Re: [RESOLVED] [2.0] Custom DateTimePicker Format
Thanks for the link.
...but isn't there any way to apply custom formatting in .NET DTPicker ?
Re: [RESOLVED] [2.0] Custom DateTimePicker Format
Oh, for that I just put a textbox under the DateTimePicker. Works really good too. You wouldn't even notice they are two different controls if you are using the program
PS :p