Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
3.67/5 (6 votes)
See more:
Hi,

Okay so after a lot of looking around and trying different things I have come to the conclusion that the standard .Net DateTimePicker doesn't provide support for picking milliseconds...despite what Microsoft documentation would suggest. I have also failed to find an example on the web of a different picker that does provide milliseconds option. My question is therefore this:

Does anyone know of a TimePicker that supports picking milliseconds or do I have to write one myself?

Thanks very much,

Ed
Posted
Comments
Sandeep Mewara 18-Mar-11 13:45pm    
I would suggest writing one for yourself would be a good idea than spending more time in searching for it.
Ed Nutting 18-Mar-11 13:46pm    
Thank you I thought that may be the answer, but it is a fair bit of work :(
Sandeep Mewara 18-Mar-11 13:49pm    
I understand, and thus I posted my suggestion as a comment and not as an answer. :)

If someone has come across it then they might post it as an answer that can help you.
wizardzz 18-Mar-11 16:01pm    
Yeah, I would suggest what Sandeep already mention. I have had to write custom controls for other things related to time input / formatting / etc. Might as well knock it out and be able to reuse it from then on. Or publish as a tip/trick or article so everyone who searches for it can use it.
Ed Nutting 18-Mar-11 16:02pm    
Yeah I am in the process of producing a time picker...nearly done :) I will then post the code as an article so that others can use it :)

I ended up answering this one myself: Time Picker[^]
 
Share this answer
 
You can try this but you need to customize the interface.
Add an usercontrol named DTMLPicker and paste these code inside of it.
C#
namespace WindowsFormsApplication1
{
    public partial class DTMLPicker : System.Windows.Forms.DateTimePicker
    {// Its an usecontrol
        public DTMLPicker()
        {
            InitializeComponent();
            System.Windows.Forms.ComboBox Cmb = 
                       new System.Windows.Forms.ComboBox();
            this.Controls.Add(Cmb);
            Cmb.Name = "Cmb";
            Cmb.Top = 0;
            Cmb.Left = 0;
            Cmb.Width = 50;
            Cmb.BringToFront();
            for (int i = 1; i <= 1000; i++)
            {
                Cmb.Items.Add(i);
            } 
            int ms = Microsoft.VisualBasic.DateAndTime.Now.Millisecond ;
            Cmb.Text = ms.ToString("D2");
        }
    }
}
 
Share this answer
 
Comments
Ed Nutting 20-Mar-11 15:33pm    
While this is a simple solution it does not solve the whole problem. For starters I then have to use a DateTimePicker and a combo box or several combo boxes - both options look bad and are confusing to a user. Secondly I can't then just get one DateTime or Timespan value I have to combine the DateTimePicker and combo box (or several combo boxes) value's which is just effort especially as it doesn't look good on screen. I wrote my TimePicker control which looks good and runs well :)
Аslam Iqbal 20-Mar-11 16:14pm    
You are right. But its a way which will show you how to start. If you are not pleased with this, you have chosen the wrong forum. No one here to do your job. I didn't tell you that it will solve your problem.
Ed Nutting 20-Mar-11 16:17pm    
If you look I have actually written and solved my problem before you tried to answer and also, my original question was if one existed, which until I wrote one, it didn't. There is a reason the button is: Submit Your **SOLUTON** Your answer 'Add an usercontrol named DTMLPicker and paste these code inside of it.' would suggest you were trying to solve my problem outright not give a starting suggestion. Anyway, I have solved my problem far better so there is not point argueing over this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900