DekGenius.com
[ Team LiB ] Previous Section Next Section

MonthCalendarmarshal by reference, disposable

System.Windows.Forms (system.windows.forms.dll)class

This Control represents a calendar for selecting a single date or a range of dates. It is more powerful than the DateTimePicker control, but it takes up a lot more real estate.

To alter the appearance of the control, you can set the CalendarDimensions to specify the number of columns and rows of months to display (1x1 would look like a single calendar month, 6x2 would allow you to display an entire year). The minimum size of any individual month can be determined with SingleMonthSize.

The current date can be shown with a circle by specifying ShowTodayCircle, or as some text at the bottom of the control with the ShowToday property. You can also change what the calendar believes to be today's date with the TodayDate property. TodayDateSet will tell you whether this has been explicitly modified. You can also specify the FirstDayOfWeek and, optionally, ShowWeekNumbers.

In addition to the standard Control appearance properties, you can independently set the TitleBackColor, TitleForeColor, and TrailingForeColor (the color of the days from last and next month that are shown on a calendar grid).

You can also set specific dates to be displayed with bold text either individually with BoldedDates, monthly with MonthlyBoldedDates, or annually with AnnuallyBoldedDates. While you can use these properties to get and set the dates concerned, they return copies of the internal date arrays. It is more efficient to use AddBoldedDate(), AddMonthlyBoldedDate(), and AddAnnuallyBoldedDate(), along with the Remove() and RemoveAll() equivalents.

Date selection can be done by setting the SelectionStart and SelectionEnd, or getting/setting both at once through the SelectionRange. You can bind to DateChanged and SelectionChanged events to be notified of the selection changing.

public class MonthCalendar : Control {
// Public Constructors
   public MonthCalendar();
// Public Instance Properties
   public DateTime[ ] AnnuallyBoldedDates{set; get; }
   public override Color BackColor{set; get; }
// overrides Control
   public override Image BackgroundImage{set; get; }
// overrides Control
   public DateTime[ ] BoldedDates{set; get; }
   public Size CalendarDimensions{set; get; }
   public Day FirstDayOfWeek{set; get; }
   public override Color ForeColor{set; get; }
// overrides Control
   public ImeMode ImeMode{set; get; }
// overrides Control
   public DateTime MaxDate{set; get; }
   public int MaxSelectionCount{set; get; }
   public DateTime MinDate{set; get; }
   public DateTime[ ] MonthlyBoldedDates{set; get; }
   public int ScrollChange{set; get; }
   public DateTime SelectionEnd{set; get; }
   public SelectionRange SelectionRange{set; get; }
   public DateTime SelectionStart{set; get; }
   public bool ShowToday{set; get; }
   public bool ShowTodayCircle{set; get; }
   public bool ShowWeekNumbers{set; get; }
   public Size SingleMonthSize{get; }
   public override string Text{set; get; }
// overrides Control
   public Color TitleBackColor{set; get; }
   public Color TitleForeColor{set; get; }
   public DateTime TodayDate{set; get; }
   public bool TodayDateSet{get; }
   public Color TrailingForeColor{set; get; }
// Protected Instance Properties
   protected override CreateParams CreateParams{get; }
// overrides Control
   protected override ImeMode DefaultImeMode{get; }
// overrides Control
   protected override Size DefaultSize{get; }
// overrides Control
// Public Instance Methods
   public void AddAnnuallyBoldedDate(DateTime date);
   public void AddBoldedDate(DateTime date);
   public void AddMonthlyBoldedDate(DateTime date);
   public SelectionRange GetDisplayRange(bool visible);
   public HitTestInfo HitTest(int x, int y);
   public HitTestInfo HitTest(System.Drawing.Point point);
   public void RemoveAllAnnuallyBoldedDates();
   public void RemoveAllBoldedDates();
   public void RemoveAllMonthlyBoldedDates();
   public void RemoveAnnuallyBoldedDate(DateTime date);
   public void RemoveBoldedDate(DateTime date);
   public void RemoveMonthlyBoldedDate(DateTime date);
   public void SetCalendarDimensions(int x, int y);
   public void SetDate(DateTime date);
   public void SetSelectionRange(DateTime date1, DateTime date2);
   public override string ToString();  // overrides System.ComponentModel.Component
   public void UpdateBoldedDates();
// Protected Instance Methods
   protected override void CreateHandle();  // overrides Control
   protected override void Dispose(bool disposing);  // overrides Control
   protected override bool IsInputKey(Keys keyData);  // overrides Control
   protected override void OnBackColorChanged(EventArgs e);  // overrides Control
   protected virtual void OnDateChanged(DateRangeEventArgs drevent);
   protected virtual void OnDateSelected(DateRangeEventArgs drevent);
   protected override void OnFontChanged(EventArgs e);  // overrides Control
   protected override void OnForeColorChanged(EventArgs e);  // overrides Control
   protected override void OnHandleCreated(EventArgs e);  // overrides Control
   protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified);  // overrides Control
   protected override void WndProc(ref Message m);  // overrides Control
// Events
   public event EventHandler Click;
// overrides Control
   public event DateRangeEventHandler DateChanged;
   public event DateRangeEventHandler DateSelected;
   public event EventHandler DoubleClick;
// overrides Control
   public event PaintEventHandler Paint;
// overrides Control
}

Hierarchy

System.Object System.MarshalByRefObject System.ComponentModel.Component(System.ComponentModel.IComponen, System.IDisposable) Control(IOleContro, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject, IOleWindow, IViewObject, IViewObject2, IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage, IQuickActivate, System.ComponentModel.ISynchronizeInvoke, IWin32Window) MonthCalendar

    [ Team LiB ] Previous Section Next Section