Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Like you were thinking in the comments, probably the simplest way to handle this is to have two <a href="http://msdn.microsoft.com/en-us/library/2687k5ae.aspx" rel="nofollow">NumericUpDown</a> controls - one that represents the day, and another that represents the hours.</p> <p>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 <a href="http://msdn.microsoft.com/en-us/library/729xt55s.aspx" rel="nofollow">MSDN documentation</a>, I think you're looking at hooking on to the <code>Click</code> event. Nothing else looks particularly interesting.</p> <p>Your code will look a little something like this:</p> <pre><code> private void ctrlUpDownHour_Click(object sender, EventArgs e) { if(ctrlUpDownHour.Value &gt;= 24) { ctrlUpDownDay.Value += 1; ctrlUpDownHour.Value -= 24; } } </code></pre> <p>Might also help if you set the <code>ctrlUpDownHour.Maximum</code> property to 24.</p> <p>EDIT: As mentioned in the comments, probably the easiest way to handle your situation is to simply make a <a href="http://msdn.microsoft.com/en-us/library/aa302342.aspx" rel="nofollow">user control</a>.</p> <p>Simply create a new user control with two <code>NumericUpDown</code> controls - get started by creating a new item in your project, and clicking on the 'user control' item - this'll get you started nicely.</p> <p>You can then visually design the <code>NumericUpDown</code> 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:</p> <pre><code>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); } } </code></pre> <p>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 <code>userControl1Instance.GetSelectedTimeSpan()</code>.</p> <p>Blammo, done.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload