A time selection control that can be used to display a null value 2

Source: Internet
Author: User
Tags bool datetime tostring
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




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.