how to set the hour of a dateTimePicker

W

Wilfried Mestdagh

Hi,

How do you set a datetimepicker (set to time only) to 00:00
programatically ?
 
B

Bill B

Here's a sample form that does it:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeTimePicker();
}

private DateTimePicker timePicker;

private void InitializeTimePicker()
{
timePicker = new DateTimePicker();
timePicker.Format = DateTimePickerFormat.Time;
timePicker.ShowUpDown = true;
timePicker.Location = new Point(10, 10);
timePicker.Width = 100;
timePicker.Visible = true;
Controls.Add(timePicker);

timePicker.Value = new DateTime(2006, 10, 30, 11, 42, 12);
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top