Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
522 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...