Question ComboBox Filling date range

Hrach23095

New member
Joined
Jul 15, 2016
Messages
2
Programming Experience
Beginner
How to fill dateTimePicker in combBox?
I want to fill date interval in my comboBox.(from 2011-01-12 to 2015-08-14)
 
How to fill dateTimePicker in combBox?
That doesn't actually make sense. A DateTimePicker is a control and a ComboBox is a different control. Which is it?
I want to fill date interval in my comboBox.(from 2011-01-12 to 2015-08-14)
So you want to populate a ComboBox with a series of dates? If so then you could do something like this:
var date = new DateTime(2011, 1, 12);
var endDate = new DateTime(2015, 8, 14);
var dates = new List<DateTime>();

do
{
    dates.Add(date);
    date = date.AddDays(1);
} while (date <= endDate);

comboBox1.DataSource = dates;
 
Back
Top Bottom