
GMonthCalendar.DrawRectangle(New Pen(Brushes.Blue, 2), intRows, intCols, 24, 15) 'Draw Rectangle AroundĪdd a button to your form, and add this code: Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If Not arrDates.Contains(oHTIMonths.Time) Then If oHTIMonths.HitArea = Then 'Is It A Date That Was Clicked On? OHTIMonths = MonthCalendar1.HitTest(intRows, intCols) 'Get Hit Info

Add this next sub: Private Sub HighlightDates() 'Draw Borders Around Datesĭim gMonthCalendar As Graphics = MonthCalendar1.CreateGraphics() 'Enable Drawing Capabilitiesĭim oHTIMonths As MonthCalendar.HitTestInfo 'Get HitTestInfoĭim arrDates As New ArrayList() 'ArrayList For Datesįor intRows As Integer = 1 To - 1 'Loop Through Width ( Rows )įor intCols As Integer = 1 To - 1 'Loop Through Columns
MENUSTRIP VISUAL BASIC CODE
The next line of code enables the MonthCalendar to make those dates bold, as in Figure 1.Īlthough having a Bolded date is quite nice and will usually suit your purpose, you can take it a step further. The first date is my birthday, then my wife’s, and finally my daughter’s. With this code, I created an array to host all the important dates I’d like to highlight inside the MonthCalendar control. MonthCalendar1.BoldedDates = dtArrSpecialDates Add the following code inside your Form’s Load event: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Loadĭim dtArrSpecialDates() As Date = New Date() Let me start with a simple functionality. You can name the objects in your project anything you like, but keep in mind that I stuck with the default names to make it simpler for you to follow.

Start a new VB.NET Windows Forms project and add one MonthCalendar control to your form. You can find all of its Properties and Methods here. It is a control that enables calendar-like capabilities and that looks like a visual representation of a month. In today’s article, I will explain all (well, most) of the little secrets of this control. As usual, I had to have a look at it myself and try to figure out precisely what can be done with a MonthCalendar control.
MENUSTRIP VISUAL BASIC HOW TO
Trouble is: How to get the secrets of the inner workings out of them….

The MonthCalendar control is actually a little gem hidden away in the deepest closets of many a programmer.
