Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to use Month Calendar Control in VB and C# (.net 2.0). Part 2

Author: Zunnair
Download Source Code : 889_window control.zip

In this simple article you will learn more about, that how can we use Month Calendar control in our application using VB and C# .net 2.0.

 

For good understanding read the first part of this article.
Minimum Space:
To get how much space is required to show the one month of the calendar control has a property named single month size. This property returns size (height, width).
To demonstrate this make a window application drag month calendar control and one button. Press the button.
Now write the following code on button click event:
 C#
private void btn_single_Click(object sender, EventArgs e)
        {
            Size s= monthCalendar1.SingleMonthSize;
            string str;
            str=s.ToString();
           MessageBox.Show(str);
        }       
VB
Private Sub btn_single_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim s As Size = monthCalendar1.SingleMonthSize
        Dim str As String
        str = s.ToString()
        MessageBox.Show(str)
    End Sub
This simple code gets the size.
Set Dimensions:
To set the dimension for the month of the calendar, month calendar control has a function named set calendar dimensions (). This function takes two integers as parameter for x and y dimensions. It returns nothing.
Write the following code.
 
 
C#
int x = 2;
int y = 2;
monthCalendar1.SetCalendarDimensions(x, y);
VB
Dim x As Integer = 2
Dim y As Integer = 2
monthCalendar1.SetCalendarDimensions(x, y)
This is a simple code to set the dimensions.
Annually Bold:
To highlight or bold a specific date in a specific month each year, for this purpose we have a function named add annually bold date (), this function takes date time class object and high light in the calendar.
To demonstrate this make a window application drag month calendar control and one button. Press the button.
Now write the following code on button click event:
 C#
private void btn_anuallybold_Click(object sender, EventArgs e)
        {
            DateTime obj = new DateTime();
            obj = monthCalendar1.SelectionStart;
            monthCalendar1.AddAnnuallyBoldedDate(obj);
        }       
VB
Private Sub btn_anuallybold_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim obj As New DateTime()
        obj = monthCalendar1.SelectionStart
        monthCalendar1.AddAnnuallyBoldedDate(obj)
    End Sub
This simple code bolds the specific day in a specific month each year.
Monthly bold:
To highlight or bold a specific date in every month, for this purpose we have a function named add monthly bold date (), this function takes date time class object and high light in the calendar.
To demonstrate this make a window application drag month calendar control and one button. Press the button.
Now write the following code on button click event:
 C#
private void btn_monthlybold_Click(object sender, EventArgs e)
        {
            DateTime obj = new DateTime();
            obj = monthCalendar1.SelectionStart;
            monthCalendar1.AddMonthlyBoldedDate(obj);
        }       
VB
Private Sub btn_monthlybold_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim obj As New DateTime()
        obj = monthCalendar1.SelectionStart
            monthCalendar1.AddMonthlyBoldedDate(obj)
    End Sub
This simple code bolds the specific day in every month.
Once bold:
To highlight or bold a specific date once, for this purpose we have a function named add bolded date (), this function takes date time class object and high light in the calendar.
To demonstrate this make a window application drag month calendar control and one button. Press the button.
Now write the following code on button click event:
 C#
private void btn_oncebold_Click(object sender, EventArgs e)
        {
            DateTime obj = new DateTime();
            obj = monthCalendar1.SelectionStart;
            monthCalendar1.AddBoldedDate(obj);
        }       
VB
Private Sub btn_oncebold_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim obj As New DateTime()
        obj = monthCalendar1.SelectionStart
            monthCalendar1.AddBoldedDate(obj)
    End Sub
This simple code bolds the specific once.
First Day of Week:
To set or get that what should be the first day in the calendar; control has a property named first day of week.
To demonstrate this make a window application drag month calendar control and one button. Press the button.
Now write the following code on button click event:
 C#
private void btn_firstday_Click(object sender, EventArgs e)
        {
            Day d;
            d=monthCalendar1.FirstDayOfWeek;
            MessageBox.Show(monthCalendar1.FirstDayOfWeek.ToString());       
        }       
VB
Private Sub btn_firstday_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim d As Day
        d = monthCalendar1.FirstDayOfWeek
        MessageBox.Show(monthCalendar1.FirstDayOfWeek.ToString())
    End Sub
This simple gets that what is the first day of week in calendar.
Now write the following code on FORM LOAD event:
C#
private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "DEVASP Month Calendar APPLICATION";
monthCalendar1.FirstDayOfWeek = Day.Monday;
        }     
VB
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Me.Text = "DEVASP Month Calendar APPLICATION"
        monthCalendar1.FirstDayOfWeek = Day.Monday;   
End Sub
 
This simple article tells that how we can use Month Calendar control in our application using VB and C# .net 2.0.

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to use Month Calendar Control in VB and C# (.net 2.0). Part 1

Disclaimer - Privacy
© 2002-2017 DevASP.net