Change month calendar size
Asked Answered
D

3

5

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

Dryad answered 13/5, 2014 at 12:49 Comment(1)
You should consider accepting the answer from Reza Aghaei.Isaiah
S
2

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

Sufism answered 13/5, 2014 at 13:33 Comment(0)
B
11

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

Birdhouse answered 27/2, 2019 at 18:54 Comment(2)
Could you explain how exactly this works? I only see the control passing its own handle to SetWindowTheme()? What theme comes into play? How does this "disable visual styles for this control"?Isaiah
@Rev1.0 By passing empty string as parameters, it disables the theme.Birdhouse
S
2

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

Sufism answered 13/5, 2014 at 13:33 Comment(0)
M
-1

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.

Makedamakefast answered 28/10, 2019 at 19:49 Comment(1)
Question was tagged WinForms.Hispaniola

© 2022 - 2024 — McMap. All rights reserved.