How can I show the month selection calendar in my application

I'm interested in showing a list of 12 months, similar to the method of choosing the date of the month. But I do not like to show the date picker, to show the dates of this month too ... only viewing the month is fine, so I can select the month from the list.

my desired result: enter image description here

+5
source share
4 answers

I'm not quite sure if I understand what you are asking. If you want to show the calendar of the month without reference to it, you can use control . MonthCalendar

It looks like this (note the lack of a text box and a drop-down arrow):

  MonthCalendar control


, , , , , . .

, , . , :

myDateTimePicker.Format = DateTimePickerFormat.Custom
myDateTimePicker.CustomFormat = "MMMM"

( , , , , ):

  DateTimePicker with custom format specified

+4

pinvoke , . DateTimePicker DropDown :

    private void dateTimePicker1_DropDown(object sender, EventArgs e) {
        IntPtr cal = SendMessage(dateTimePicker1.Handle, DTM_GETMONTHCAL, IntPtr.Zero, IntPtr.Zero);
        SendMessage(cal, MCM_SETCURRENTVIEW, IntPtr.Zero, (IntPtr)1);
    }

    // pinvoke:
    private const int DTM_GETMONTHCAL = 0x1000 + 8;
    private const int MCM_SETCURRENTVIEW = 0x1000 + 32;

    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);

, . Windows Vista. -, # VB.NET

+6

" " "" , "MMMM", . true, .

0

MonthCalendar GroupBox. GroupBox , MonthCalendar. .

-1
source

All Articles