DekGenius.com
[ Team LiB ] Previous Section Next Section

DateTimePickermarshal by reference, disposable

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

This Control class wraps the Win32 date/time selection common control. This is perhaps the least used of all the common controls—most commercial applications seem to roll their own Outlook-style date and time pickers (or use one of several third-party controls available).

First, you can set the Format of the control. This can cause considerable changes in behavior from a Long or Short date (in which case you are provided with a drop-down calendar date picker and a formatted date edit field) to a Time (in which case you lose the calendar and gain a formatted time edit field). There is also Custom, which requires you to set the CustomFormat property and use your own date-time format string. The standard formats are derived from the system locale settings.

As well as the standard Control appearance properties, you can independently set the CalendarFont, CalendarForeColor, CalendarMonthBackground, CalendarTitleBackColor, CalendarTitleForeColor, and CalendarTrailingForeColor (that's the color of the days from last and next month that are shown on this months calendar grid). You can choose how the calendar drop-down menu is aligned (to the LeftRightAlignment.Left or Right edge of the control), by using the DropDownAlign property.

The control can display a checkbox using the ShowCheckBox property. It indicates whether a value is actually selected (Checked)—this lets you support null dates. You can also add a spin button with ShowUpDown that gives you another way to adjust the date.

The date range available can be set with MaxDate and MinDate (and there are static MaxDateTime and MinDateTime properties, which get the theoretical maximum and minimum values, that can be displayed by the control). However, you can only select a single Value in the control, which defaults to DateTime.Now. Compare this to the MonthCalendar control which allows you to select a range of dates, embolden certain dates, etc.

public class DateTimePicker : Control {
// Public Constructors
   public DateTimePicker();
// Public Static Fields
   public static readonly DateTime MaxDateTime;  // =12/31/9998 12:00:00 AM
   public static readonly DateTime MinDateTime;  // =1/1/1753 12:00:00 AM
// Protected Static Fields
   protected static readonly Color DefaultMonthBackColor;  // =Color [Window]
   protected static readonly Color DefaultTitleBackColor;  // =Color [ActiveCaption]
   protected static readonly Color DefaultTitleForeColor;  // =Color [ActiveCaptionText]
   protected static readonly Color DefaultTrailingForeColor;  // =Color [GrayText]
// Public Instance Properties
   public override Color BackColor{set; get; } // overrides Control
   public override Image BackgroundImage{set; get; } // overrides Control
   public Font CalendarFont{set; get; }
   public Color CalendarForeColor{set; get; }
   public Color CalendarMonthBackground{set; get; }
   public Color CalendarTitleBackColor{set; get; }
   public Color CalendarTitleForeColor{set; get; }
   public Color CalendarTrailingForeColor{set; get; }
   public bool Checked{set; get; }
   public string CustomFormat{set; get; }
   public LeftRightAlignment DropDownAlign{set; get; }
   public override Color ForeColor{set; get; } // overrides Control
   public DateTimePickerFormat Format{set; get; }
   public DateTime MaxDate{set; get; }
   public DateTime MinDate{set; get; }
   public int PreferredHeight{get; }
   public bool ShowCheckBox{set; get; }
   public bool ShowUpDown{set; get; }
   public override string Text{set; get; } // overrides Control
   public DateTime Value{set; get; }
// Protected Instance Properties
   protected override CreateParams CreateParams{get; } // overrides Control
   protected override Size DefaultSize{get; } // overrides Control
// Public Instance Methods
   public override string ToString();  // overrides System.ComponentModel.Component
// Protected Instance Methods
   protected override AccessibleObject CreateAccessibilityInstance();  // overrides Control
   protected override void CreateHandle();  // overrides Control
   protected override void DestroyHandle();  // overrides Control
   protected override bool IsInputKey(Keys keyData);  // overrides Control
   protected virtual void OnCloseUp(EventArgs eventargs);
   protected virtual void OnDropDown(EventArgs eventargs);
   protected override void OnFontChanged(EventArgs e);  // overrides Control
   protected virtual void OnFormatChanged(EventArgs e);
   protected override void OnSystemColorsChanged(EventArgs e);  // overrides Control
   protected virtual void OnValueChanged(EventArgs eventargs);
   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 CloseUp;
   public event EventHandler DropDown;
   public event EventHandler FormatChanged;
   public event PaintEventHandler Paint; // overrides Control
   public event EventHandler ValueChanged;
}

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) DateTimePicker

Passed To

DateTimePickerAccessibleObject.DateTimePickerAccessibleObject()

    [ Team LiB ] Previous Section Next Section