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 3

Author: Zunnair
Download Source Code : 890_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 and second part of this article.
Set and Get Maximum Allowable Date:
To set or get the maximum date range which calendar can provide. For this purpose month calendar control provides us a property named max date. This property takes and returns the date time class object.
Set Max Range:
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_setrange_Click(object sender, EventArgs e)
        {
            DateTime obj = new DateTime();
            obj = DateTime.Now;
            obj.AddYears(1);
            obj.AddMonths(0);
            obj.AddDays(0);
            monthCalendar1.MaxDate = obj;
        }
VB
Private Sub btn_setrange_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim obj As New DateTime()
        obj = DateTime.Now
        obj.AddYears(1)
        obj.AddMonths(0)
        obj.AddDays(0)
        monthCalendar1.MaxDate = obj
    End Sub
This simple code sets the maximum range.
Get Max Range:
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_getrange_Click(object sender, EventArgs e)
        {
            DateTime obj = new DateTime();
            obj = monthCalendar1.MaxDate;
            MessageBox.Show(obj.ToString());
        }
VB
Private Sub btn_getrange_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim obj As New DateTime()
        obj = monthCalendar1.MaxDate
        MessageBox.Show(obj.ToString())
    End Sub
This simple code gets the maximum range.
Set and Get Minimum Allowable Date:
To set or get the minimum date range which calendar can provide. For this purpose month calendar control provides us a property named min date. This property takes and returns the date time class object.
Set Min Range:
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_setmin_Click(object sender, EventArgs e)
        {
            DateTime obj = new DateTime();
            obj = DateTime.Now;
            obj.AddYears(1);
            obj.AddMonths(0);
            obj.AddDays(0);
            monthCalendar1.MinDate = obj;
        }
VB
Private Sub btn_setmin_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim obj As New DateTime()
        obj = DateTime.Now
        obj.AddYears(1)
        obj.AddMonths(0)
        obj.AddDays(0)
        monthCalendar1.MinDate = obj
    End Sub
This simple code sets the minimum range.
Get Min Range:
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_getmin_Click(object sender, EventArgs e)
        {
            DateTime obj = new DateTime();
            obj = monthCalendar1.MinDate;
            MessageBox.Show(obj.ToString());
        }
VB
Private Sub btn_getmin_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim obj As New DateTime()
        obj = monthCalendar1.MinDate
        MessageBox.Show(obj.ToString())
    End Sub
This simple code gets the minimum range.
Selection of Days:
To set or get the limit that how many days can be selected at a time, control has a property which provides us this facility. Property name is max selection count this property takes integer and returns integer.
Set Limit:
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_setlimit_Click(object sender, EventArgs e)
        {
            int l = 5;
            monthCalendar1.MaxSelectionCount = l;
        }
VB
Private Sub btn_setlimit_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim l As Integer = 5
        monthCalendar1.MaxSelectionCount = l
    End Sub
This simple code sets the limit.
Get Limit:
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_getlimit_Click(object sender, EventArgs e)
        {
            int l;
            l = monthCalendar1.MaxSelectionCount;
            string str;
            str = l.ToString();
            MessageBox.Show(str);
        }
VB
Private Sub btn_getlimit_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim l As Integer
        l = monthCalendar1.MaxSelectionCount
        Dim str As String
        str = l.ToString()
        MessageBox.Show(str)
    End Sub
This simple code gets the limit.
Now write the following code on FORM LOAD event:
C#
private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "DEVASP Month Calendar APPLICATION";
        }     
VB
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Me.Text = "DEVASP Month Calendar APPLICATION"
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 2

Disclaimer - Privacy
© 2002-2017 DevASP.net