Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8939197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:46:33+00:00 2026-06-15T10:46:33+00:00

I need a way to create a TimeSpan time picker column, that allow more

  • 0

I need a way to create a TimeSpan time picker column, that allow more than 24 hours. Right now, I got a TimePicker which derived from the DateTimePicker, but after 24, it turn back to zero. And I didn’t find a way to change it’s behaviour.

Please help.

thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:46:34+00:00Added an answer on June 15, 2026 at 10:46 am

    Like you were thinking in the comments, probably the simplest way to handle this is to have two NumericUpDown controls – one that represents the day, and another that represents the hours.

    From there, you will need to add a bit of extra logic. These spinners don’t natively support ‘rolling over’, so you’ll have to code it yourself. You add these to events, and looking through the MSDN documentation, I think you’re looking at hooking on to the Click event. Nothing else looks particularly interesting.

    Your code will look a little something like this:

     private void ctrlUpDownHour_Click(object sender, EventArgs e)
     {
        if(ctrlUpDownHour.Value >= 24)
        {
            ctrlUpDownDay.Value += 1;
            ctrlUpDownHour.Value -= 24;
        }
     }
    

    Might also help if you set the ctrlUpDownHour.Maximum property to 24.

    EDIT: As mentioned in the comments, probably the easiest way to handle your situation is to simply make a user control.

    Simply create a new user control with two NumericUpDown controls – get started by creating a new item in your project, and clicking on the ‘user control’ item – this’ll get you started nicely.

    You can then visually design the NumericUpDown controls however you want. After that’s taken care of, you can go into your code-behind, and have something that looks a little like this:

    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
             InitializeComponent();
             // anything else you want to do here
        }
    
        public TimeSpan GetSelectedTimeSpan()
        {
           return new TimeSpan((int)numericUpDown1.Value, (int)numericUpDown2.Value, 0, 0);
        }
    }
    

    You can then place this user control like any other control on any of your other forms. Then when you need the TimeSpan from it, you’ll just capture the control the same as you would any other control and go userControl1Instance.GetSelectedTimeSpan().

    Blammo, done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a way to create variables that are accessible for the entire time
I need a way to create an extension method off of an IEnumerable that
I need to know if there is a way to create a custom shortcut
I need a way to change the specific value of a column of a
I need a way to create an invoice from multiple orders every month? In
I need a way to create an object from a location value. For example
What's the best way to create a real-time communication with wcf? I.e. for games,
I need a way to create a string of n chars. In this case
I need to create a table that has some fields that another one has
I have user typed times that need parsing into DateTime or TimeSpan (the date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.