A time selection control that can be used to display a null value 2
Last Update:2017-02-28
Source: Internet
Author: User
Control | Displays the using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Drawing;
Using System.Data;
Using System.Windows.Forms;
Namespace Xpanglib
{
<summary>
Summary description of the dateinput.
</summary>
public class DateInput:System.Windows.Forms.UserControl
{
#region Member Control
Private System.Windows.Forms.MonthCalendar Calendar;
Private System.Windows.Forms.Form Frmcalendar;
Private System.Windows.Forms.Panel panel3;
Private System.Windows.Forms.Button Btnmain;
Private System.Windows.Forms.VScrollBar UpDown;
Private System.Windows.Forms.Panel Panel1;
Private System.Windows.Forms.Panel Panel2;
Private System.Windows.Forms.Label lbSep3;
Private System.Windows.Forms.TextBox Tbday;
Private System.Windows.Forms.Label LbSep2;
Private System.Windows.Forms.TextBox Tbmonth;
Private System.Windows.Forms.Label LbSep1;
Private System.Windows.Forms.TextBox tbyear;
Private System.Windows.Forms.Label Label2;
Private System.Windows.Forms.Label Lbspace;
#endregion
<summary>
The required designer variable.
</summary>
Private System.ComponentModel.Container components = null;
Private ContextMenu mnu = new ContextMenu ();
#region Custom Properties
[Browsable (True), ReadOnly (false)]
Public size Size
{
Set
{
Base. size = new Size (value. WIDTH,21);
This. SetBounds (base. Location.x,base. Location.y,this. Width,base. Height);
This. Refresh ();
}
Get
{
Return base. Size;
}
}
private string Strdateformat;
[CategoryAttribute ("Show properties and Values"),
TypeConverterAttribute (typeof (Dateformatconverter)),
DescriptionAttribute ("Time display format"),
ReadOnlyAttribute (false)]
public string DateFormat
{
Get
{
return strdateformat;
}
Set
{
Strdateformat = value;
Refreshdisplay ();
}
}
private string Strfomatchar;
[CategoryAttribute ("Show properties and Values"),
DescriptionAttribute ("Custom display format"),
ReadOnlyAttribute (false)]
public string Fomatchar
{
Get
{
return Strfomatchar;
}
Set
{
Strfomatchar = value;
Refreshdisplay ();
}
}
BOOL Blshowupdown = false;
[CategoryAttribute ("Show properties and Values"),
DescriptionAttribute ("Show UpDown button"),
ReadOnlyAttribute (false)]
public bool Showupdown
{
Get
{
return blshowupdown;
}
Set
{
Blshowupdown = value;
this.btnMain.Visible =!value;
This. updown.visible = value;
}
}
Private DateTime Dtvalue;
<summary>
The date selected
</summary>
[CategoryAttribute ("Show properties and Values"),
DescriptionAttribute ("Selected value"),
ReadOnlyAttribute (false)]
Public DateTime Value
{
Get
{
if (IsNull ())
Dtvalue = Datetime.minvalue;
Else
{
string stryear = Tbyear.text;
string strmonth = Tbmonth.text;
string strday = Tbday.text;
String strdate = Stryear + "-" + Strmonth + "-" +strday;
Dtvalue = DateTime.Parse (strdate);
}
return dtvalue;
}
Set
{
Dtvalue = value;
if (Dtvalue = = Datetime.minvalue)
Emptyinput ();
Else
{
Tbyear.text = DtValue.Year.ToString ();
Tbmonth.text = DtValue.Month.ToString ();
Tbday.text = DtValue.Day.ToString ();
}
This. Refresh ();
}
}
#endregion