PenguinSh
PenguinSh

Reputation: 119

How to hide next/preivous button of MonthCalendar control in C#

I have a project and i want to hide next/preivous button of MonthCalendar control in C#. I have searched Google but i can't find the solution. Please show me.

Upvotes: 1

Views: 1747

Answers (2)

Ian Sexton
Ian Sexton

Reputation: 1

Don't forget to add the Hours, Minutes and Seconds... Especially useful for avoiding exceptions on MaxDate.

DateTime firstDayInMonth = new DateTime(today.Year, today.Month, 1, 0, 0, 0);
DateTime lastDayInMonth = new DateTime(today.Year, today.Month, DateTime.DaysInMonth(today.Year, today.Month), 23, 59, 59);

yourCalendar.MinDate = firstDayInMonth;
yourCalendar.MaxDate = lastDayInMonth;

Upvotes: 0

Wanabrutbeer
Wanabrutbeer

Reputation: 697

You can disable them by setting the control's MinDate and MaxDate properties, programmatically set MinDate to day 1 of this month, and MaxDate to whatever the last day of this month is.

Upvotes: 3

Related Questions