.NET Monthly Month Management

Is there an election control only for winforms? I need to allow the user to select the month regardless of the day of the month.

Thank.

+3
source share
5 answers

I do not know such control. Could you add months to Listbox or Combobox and have them that way?

+1
source

There is another answer using custom date picker formats: looking for a month / year selector control for .net winform This works fine, although you don't get a drop-down, just the up / down buttons for month and year.

+3
source

There is no such standard control, but it’s easy for me to do it myself, add all the months to the Drop Down control.

+1
source

Just for fun, the name of the month is ComboBox in three lines:

comboBox1.DataSource = new BindingSource(
    System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames
        .Where(m => m != String.Empty)
        .Select((m, i) => new { Name = m, Index = i })
        .ToDictionary(x => x.Index, x => x.Name),
    null);
comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";

Now there comboBox1.SelectedValuewill be 0..11 depdending in the selected month.

+1
source

You can use DateTimePickerwith a custom format to include only a month to indicate the following:

DateTimePicker dateTimePicker1 = new DateTimePicker();
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM"; // for May, June, July etc. format
dateTimePicker1.ShowUpDown = true; // prevents the calendar from being displayed
+1
source

Source: https://habr.com/ru/post/1736873/


All Articles