Results 1 to 10 of 10

Thread: [RESOLVED] [2.0] Custom DateTimePicker Format

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Resolved [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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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]
    Attached Files Attached Files
    Last edited by iPrank; Apr 12th, 2006 at 11:18 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    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?

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    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.

  7. #7
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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 !
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    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

  9. #9
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: [RESOLVED] [2.0] Custom DateTimePicker Format

    Thanks for the link.
    ...but isn't there any way to apply custom formatting in .NET DTPicker ?
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width