Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had the same problem and found a workaround:</p> <p>It seems that the dimensions of the <code>MonthCalendar</code> control are updated correctly when it is shown (like in a form) in runtime.</p> <p>Use, e.g., the form's <code>Shown</code> event to know when the dimensions are updated.</p> <p>You can also set the form's <code>AutoSize</code> property to <code>true</code> and <code>AutoSizeMode</code> to <code>GrowAndShrink</code> to make the form automatically fit the <code>MonthCalendar</code> control.</p> <p>Update:</p> <p>For more details try this example:</p> <p>Put a MonthCalendar control on a form like this:</p> <p><img src="https://i.stack.imgur.com/eLW7f.jpg" alt="Form with MonthCalender control"></p> <p>In the <strong>form's</strong> Shown event add this:</p> <pre><code>public static int CalenderWidth = 0, CalenderHeight = 0; private void Form1_Shown(object sender, EventArgs e) { CalenderWidth = monthCalendar1.Width; CalenderHeight = monthCalendar1.Height; MessageBox.Show("MonthControl width: " + CalenderWidth.ToString() + ", height: " + CalenderHeight.ToString()); } </code></pre> <p>When the program is run you will see a messagebox showing the right dimensions. The Width and Height are also put into two variables you can use anywhere in your program (in a quick and dirty way, I know ;-) Of course you can omit the messagebox if you don't want it.</p> <p>To check it is really working try changing the Region settings in Windows: Change the Format to e.g. Danish. Run the program again and you will see the Width has gotten smaller because a Danish MonthCalender control is smaller.</p> <p>Regarding the <code>AutoSize</code>and <code>AutoSizeMode</code> properties they can be used to make the size of the form adapt to the size of the MonthCalender control. Do this: Change the two properties in the <strong>form</strong> into this:</p> <p><img src="https://i.stack.imgur.com/xYfbz.jpg" alt="Form&#39;s properties (Visual Studio)"></p> <p>Now run the program and you will see that the size of the form changes automatically depending of the size of the MonthCalender control:</p> <p><img src="https://i.stack.imgur.com/ibVIh.jpg" alt="Result"></p> <p>That's it! (remember to switch your Region format setting back to the original one)</p> <p>;-) Dave</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload