Change month calendar size

ⅰ亾dé卋堺 提交于 2019-11-28 04:33:38

问题


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


回答1:


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




回答2:


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):

Comparing to the default appearance:




回答3:


You can also put the calendar widget into a "Viewbox" widget. The calendar will resize with the viewbox. Link to my source (28/10/2019): https://www.wpf-tutorial.com/misc-controls/the-calendar-control/ I hope I could help you.



来源:https://stackoverflow.com/questions/23631784/change-month-calendar-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!