DateTime now = DateTime.Now;
List<DateTime> dates = new List<DateTime>();
dates.Add(now);
dates.Add(now.AddMonths(6));
dates.Add(now.AddMonths(1));
dates.Add(now.AddYears(1));
comboBoxDates.DataSource = dates;
I would use a loop and go through the list, and make another list without the days and house:minutes.. but I’m sure there are better ways to do this.
Thank you in advance!
It depends on what you are trying to achieve, but in general, you can bind
List<DateTime>to your combobox like you do it and then just set itsFormatStringto whatever you need:This approach allows you to configure what is being displayed to users, and in code you can still work with
DateTimebound.