Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change month calendar size

Is there any possible way to change the calendar control width and height . I want to change the width and height of the calendar . These step when i google i found 1) Drop the month calendar in panel and allow dropping true . And Increase the size the panel . Does not work for me . 2) Drop the month calendar calendar in group box and dock fill . This display many months with the this month. 3) Increase the font size of the calendar control, does not work for me.

Is there any way to do this . Thanks in advance for your comments

like image 212
A.Goutam Avatar asked May 13 '14 12:05

A.Goutam


2 Answers

When the MonthCalendar control is rendered using visual styles, its size just follows system settings and you cannot change its size. However, as an option you can disable visual styles for this control and set a larger font for the control to change its size using SetWindowTheme:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class MyMonthCalendar : MonthCalendar
{
    [DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
    static extern int SetWindowTheme(IntPtr hwnd, string pszSubAppName, string pszSubIdList);
    protected override void OnHandleCreated(EventArgs e)
    {
        SetWindowTheme(Handle, string.Empty, string.Empty);
        base.OnHandleCreated(e);
    }
}

Then it will appear like this (Font-size: 16):

enter image description here

Comparing to the default appearance:

enter image description here

like image 57
Reza Aghaei Avatar answered Nov 11 '22 05:11

Reza Aghaei


Sadly, you cannot resize the month calendar control, at least not they way you want.

The only "resize" there is will just add another month below the first one (you can achieve this by increasing the Minimum Size property).

If you want to resize the control but still show only one month, you will have to make your own control, or use any 3rd party one, like this

like image 2
MozesM Avatar answered Nov 11 '22 06:11

MozesM