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.
Thanks for this kind of blog...
ReplyDeleteThanks for your valuable comment.
Delete