Friday, 30 May 2014

How to get the selected date of a MonthCalendar control in C#

5/30/2014 - By Pranav Singh 2

MonthCalendar is one of the most important calendar control. This control is used for selecting the date and range of the date. 

In my previous article I have show you Create MDI Form in C# | C# MDI Form . For opening the MDI form in windows application refer the article Open For MDI Parent Using C#.Net and VB.Net. For opening a command prompt on button click of the application is as follows How to Open Command Prompt Using C#.net.

So in this article I will show you how you can use the MonthCalender in your windows application and how you can display the selected date in textbox control.

Now for this article first we will create a new windowsapplication add the below code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace ProjectDemo_Windows
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            textBox1.Text = monthCalendar1.SelectionRange.Start.ToShortDateString();
        }
    }
}

In above code please check he bold part of the code. In this I have assign the selected value of the date to the textbox control.


Now run the application for desired output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

2 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top