Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views3 pages

Calendarcontrol Program

The document outlines the design of a C# application for selecting a single day using a calendar control. It includes an algorithm detailing the steps to initialize the form, set up the calendar for single-day selection, and update a label with the selected date. The provided C# code implements these functionalities, including event handling for date changes.

Uploaded by

monishkumar879
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Calendarcontrol Program

The document outlines the design of a C# application for selecting a single day using a calendar control. It includes an algorithm detailing the steps to initialize the form, set up the calendar for single-day selection, and update a label with the selected date. The provided C# code implements these functionalities, including event handling for date changes.

Uploaded by

monishkumar879
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Set B

19) Design an application for selecting a single day in the calendar


control.
Aim:
To design an application for selecting a single day in the calendar
control.
Algorithm:

Step 1: Start the program and initialize the form.

Step 2: Set the calendar control (monthCalendar1) to only allow


selecting one day at a time by setting MaxSelectionCount to 1.

Step 3: Set the label (label1) text to prompt the user to select a date,
e.g., "Select a date".

Step 4: Attach an event handler to the calendar's DateChanged event


so that when the user changes the date selection, the program reacts.

Step 5: When the user selects a date on the calendar:

o Capture the selected date (e.Start).


o Update the label text to show the selected date in a short date
format, e.g., "Selected Date: 7/7/2025".

Step 6: The form is displayed with the calendar and label showing
current state.

Step 7: Stop the program.

C# code:

using System;
using System.Windows.Forms;

namespace singledayselectorapp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Limit calendar selection to a single day
monthCalendar1.MaxSelectionCount = 1;

// Set initial label text


label1.Text = "Select a date";

// Attach event handler for date changes


monthCalendar1.DateChanged += MonthCalendar1_DateChanged;
}

private void MonthCalendar1_DateChanged(object sender,


DateRangeEventArgs e)
{
// Update the label with the selected date
label1.Text = "Selected Date: " + e.Start.ToShortDateString();
}

private void Form1_Load(object sender, EventArgs e)


{

private void monthCalendar_Click(object sender, EventArgs e)


{

private void monthCalendar1_DateChanged_1(object sender,


DateRangeEventArgs e)
{

}
}
}
OUTPUT:

You might also like