Represents a standard Windows month calendar control.
public class MonthCalendar: Control
Object
// This sample shows how to create and use a MonthCalendar instance.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace SimpleMonthCalendar
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MonthCalendar monthCalendar1= null;
private System.Windows.Forms.Label label1= null;
private System.Windows.Forms.Label label2= null;
public Form1()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.monthCalendar1
= new System.Windows.Forms.MonthCalendar();this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
// monthCalendar1
this.monthCalendar1.Location = new System.Drawing.Point(10, 10);
this.monthCalendar1.DateChanged += new DateRangeEventHandler(on_date_changed);
this.monthCalendar1.DateSelected += new System.Windows.Forms.DateRangeEventHandler(on_date_selected);
// Sets the dimensions of the calendar to 2 rows by 2 columns.
this.monthCalendar1.CalendarDimensions = new System.Drawing.Size(2, 2);
// Sets the beginning day of the week.
this.monthCalendar1.FirstDayOfWeek = System.Windows.Forms.Day.Monday;
// Sets the maximum days that can be selected in one selection.
this.monthCalendar1.MaxSelectionCount = 21;
// Sets the scroll rate.
this.monthCalendar1.ScrollChange = 1;
// Shows today's date.
this.monthCalendar1.ShowToday = true;
// Circles today's date.
this.monthCalendar1.ShowTodayCircle = true;
// Shows the week numbers.
this.monthCalendar1.ShowWeekNumbers = true;
// label1
this.label1.Location = new System.Drawing.Point(10, this.monthCalendar1.Bottom + 10 );
this.label1.Size = new System.Drawing.Size(360, 100 );
// label2
this.label2.Location = new System.Drawing.Point(10, this.label1.Bottom + 10 );
this.label2.Size = new System.Drawing.Size(360, 100 );
// Form1
this.Controls.Add(this.monthCalendar1);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
}
private void on_date_changed( object sender, DateRangeEventArgs e )
{
this.label1.Text= "OnDateChanged= [" + e.Start.ToShortDateString()
+ "-" + e.End.ToShortDateString() + "]";
}
private void on_date_selected( object sender, System.Windows.Forms.DateRangeEventArgs e)
{
this.label2.Text = "OnDateSelected= [" + e.Start.ToShortDateString()
+ "-" + e.End.ToShortDateString() + "]";
}
static void Main()
{
Application.Run( new Form1() );
}
}
}
Namespace System.Windows.Forms Flash Library System.Windows.Forms.scl Flash Library Version 2.0.0.2118 Silverlight Library System.Windows.Forms.dll
| © 2003-2007 NETiKA Technologies. All rights reserved. |