分享
 
 
 

可用来显示空值的时间选择控件4

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

#region 组件设计器生成的代码

/// <summary>

/// 设计器支持所需的方法 - 不要使用代码编辑器

/// 修改此方法的内容。

/// </summary>

private void InitializeComponent()

{

this.panel3 = new System.Windows.Forms.Panel();

this.panel1 = new System.Windows.Forms.Panel();

this.panel2 = new System.Windows.Forms.Panel();

this.lbSpace = new System.Windows.Forms.Label();

this.lbSep3 = new System.Windows.Forms.Label();

this.tbDay = new System.Windows.Forms.TextBox();

this.lbSep2 = new System.Windows.Forms.Label();

this.tbMonth = new System.Windows.Forms.TextBox();

this.lbSep1 = new System.Windows.Forms.Label();

this.tbYear = new System.Windows.Forms.TextBox();

this.label2 = new System.Windows.Forms.Label();

this.btnMain = new System.Windows.Forms.Button();

this.UpDown = new System.Windows.Forms.VScrollBar();

this.panel3.SuspendLayout();

this.panel1.SuspendLayout();

this.panel2.SuspendLayout();

this.SuspendLayout();

//

// panel3

//

this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

this.panel3.Controls.Add(this.panel1);

this.panel3.Controls.Add(this.btnMain);

this.panel3.Controls.Add(this.UpDown);

this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;

this.panel3.Location = new System.Drawing.Point(0, 0);

this.panel3.Name = "panel3";

this.panel3.Size = new System.Drawing.Size(104, 24);

this.panel3.TabIndex = 210;

//

// panel1

//

this.panel1.Controls.Add(this.panel2);

this.panel1.Controls.Add(this.label2);

this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;

this.panel1.Location = new System.Drawing.Point(0, 0);

this.panel1.Name = "panel1";

this.panel1.Size = new System.Drawing.Size(84, 20);

this.panel1.TabIndex = 212;

//

// panel2

//

this.panel2.Controls.Add(this.lbSpace);

this.panel2.Controls.Add(this.lbSep3);

this.panel2.Controls.Add(this.tbDay);

this.panel2.Controls.Add(this.lbSep2);

this.panel2.Controls.Add(this.tbMonth);

this.panel2.Controls.Add(this.lbSep1);

this.panel2.Controls.Add(this.tbYear);

this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;

this.panel2.Location = new System.Drawing.Point(0, 2);

this.panel2.Name = "panel2";

this.panel2.Size = new System.Drawing.Size(84, 18);

this.panel2.TabIndex = 207;

//

// lbSpace

//

this.lbSpace.BackColor = System.Drawing.SystemColors.Window;

this.lbSpace.Dock = System.Windows.Forms.DockStyle.Fill;

this.lbSpace.Location = new System.Drawing.Point(70, 0);

this.lbSpace.Name = "lbSpace";

this.lbSpace.Size = new System.Drawing.Size(14, 18);

this.lbSpace.TabIndex = 223;

this.lbSpace.TextAlign = System.Drawing.ContentAlignment.TopCenter;

this.lbSpace.Click += new System.EventHandler(this.lbSpace_Click);

this.lbSpace.EnabledChanged += new System.EventHandler(this.lbSep1_EnabledChanged);

//

// lbSep3

//

this.lbSep3.AutoSize = true;

this.lbSep3.BackColor = System.Drawing.SystemColors.Window;

this.lbSep3.Dock = System.Windows.Forms.DockStyle.Left;

this.lbSep3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

this.lbSep3.Location = new System.Drawing.Point(70, 0);

this.lbSep3.Name = "lbSep3";

this.lbSep3.Size = new System.Drawing.Size(0, 17);

this.lbSep3.TabIndex = 220;

this.lbSep3.EnabledChanged += new System.EventHandler(this.lbSep1_EnabledChanged);

//

// tbDay

//

this.tbDay.AutoSize = false;

this.tbDay.BorderStyle = System.Windows.Forms.BorderStyle.None;

this.tbDay.Dock = System.Windows.Forms.DockStyle.Left;

this.tbDay.Location = new System.Drawing.Point(58, 0);

this.tbDay.Name = "tbDay";

this.tbDay.Size = new System.Drawing.Size(12, 18);

this.tbDay.TabIndex = 219;

this.tbDay.Text = "12";

this.tbDay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;

this.tbDay.WordWrap = false;

this.tbDay.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbMonth_KeyDown);

this.tbDay.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbDay_KeyPress);

//

// lbSep2

//

this.lbSep2.AutoSize = true;

this.lbSep2.BackColor = System.Drawing.SystemColors.Window;

this.lbSep2.Dock = System.Windows.Forms.DockStyle.Left;

this.lbSep2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

this.lbSep2.Location = new System.Drawing.Point(47, 0);

this.lbSep2.Name = "lbSep2";

this.lbSep2.Size = new System.Drawing.Size(11, 17);

this.lbSep2.TabIndex = 218;

this.lbSep2.Text = "-";

this.lbSep2.EnabledChanged += new System.EventHandler(this.lbSep1_EnabledChanged);

//

// tbMonth

//

this.tbMonth.AutoSize = false;

this.tbMonth.BorderStyle = System.Windows.Forms.BorderStyle.None;

this.tbMonth.Dock = System.Windows.Forms.DockStyle.Left;

this.tbMonth.Location = new System.Drawing.Point(35, 0);

this.tbMonth.Name = "tbMonth";

this.tbMonth.Size = new System.Drawing.Size(12, 18);

this.tbMonth.TabIndex = 217;

this.tbMonth.Text = "12";

this.tbMonth.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;

this.tbMonth.WordWrap = false;

this.tbMonth.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbMonth_KeyDown);

this.tbMonth.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbMonth_KeyPress);

this.tbMonth.Leave += new System.EventHandler(this.tbMonth_Leave);

this.tbMonth.Enter += new System.EventHandler(this.tbMonth_Enter);

//

// lbSep1

//

this.lbSep1.AutoSize = true;

this.lbSep1.BackColor = System.Drawing.SystemColors.Window;

this.lbSep1.Dock = System.Windows.Forms.DockStyle.Left;

this.lbSep1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

this.lbSep1.Location = new System.Drawing.Point(24, 0);

this.lbSep1.Name = "lbSep1";

this.lbSep1.Size = new System.Drawing.Size(11, 17);

this.lbSep1.TabIndex = 216;

this.lbSep1.Text = "-";

this.lbSep1.EnabledChanged += new System.EventHandler(this.lbSep1_EnabledChanged);

//

// tbYear

//

this.tbYear.AutoSize = false;

this.tbYear.BorderStyle = System.Windows.Forms.BorderStyle.None;

this.tbYear.Dock = System.Windows.Forms.DockStyle.Left;

this.tbYear.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.tbYear.Location = new System.Drawing.Point(0, 0);

this.tbYear.Name = "tbYear";

this.tbYear.RightToLeft = System.Windows.Forms.RightToLeft.No;

this.tbYear.Size = new System.Drawing.Size(24, 18);

this.tbYear.TabIndex = 211;

this.tbYear.Text = "2004";

this.tbYear.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;

this.tbYear.WordWrap = false;

this.tbYear.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbMonth_KeyDown);

this.tbYear.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbYear_KeyPress);

this.tbYear.Leave += new System.EventHandler(this.tbYear_Leave);

this.tbYear.Enter += new System.EventHandler(this.tbMonth_Enter);

//

// label2

//

this.label2.BackColor = System.Drawing.SystemColors.Window;

this.label2.Dock = System.Windows.Forms.DockStyle.Top;

this.label2.Location = new System.Drawing.Point(0, 0);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(84, 2);

this.label2.TabIndex = 206;

this.label2.EnabledChanged += new System.EventHandler(this.lbSep1_EnabledChanged);

//

// btnMain

//

this.btnMain.Dock = System.Windows.Forms.DockStyle.Right;

this.btnMain.Location = new System.Drawing.Point(84, 0);

this.btnMain.Name = "btnMain";

this.btnMain.Size = new System.Drawing.Size(16, 20);

this.btnMain.TabIndex = 811;

this.btnMain.Click += new System.EventHandler(this.btnMain_Click);

this.btnMain.Paint += new System.Windows.Forms.PaintEventHandler(this.btnMain_Paint);

//

// UpDown

//

this.UpDown.Dock = System.Windows.Forms.DockStyle.Right;

this.UpDown.Location = new System.Drawing.Point(100, 0);

this.UpDown.Name = "UpDown";

this.UpDown.Size = new System.Drawing.Size(0, 20);

this.UpDown.TabIndex = 210;

this.UpDown.Visible = false;

this.UpDown.Scroll += new System.Windows.Forms.ScrollEventHandler(this.UpDown_Scroll);

//

// DateInput

//

this.Controls.Add(this.panel3);

this.Name = "DateInput";

this.Size = new System.Drawing.Size(104, 24);

this.Leave += new System.EventHandler(this.DateInput_Leave);

this.panel3.ResumeLayout(false);

this.panel1.ResumeLayout(false);

this.panel2.ResumeLayout(false);

this.ResumeLayout(false);

}

#endregion

private void tbYear_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

{

if (this.DesignMode)

return ;

TextBox obj = (TextBox)sender ;

obj.SelectedText = "" ;

string strValue = obj.Text ;

int iLen= strValue.ToString().Length ;

int key = (int)(e.KeyChar) ;

switch(key)

{

case 48://0

case 49://1

case 50://2

case 51://3

case 52://4

case 53://5

case 54://6

case 55://7

case 56://8

case 57://9

e.Handled = false ;

if (iLen == 3)

obj.Parent.SelectNextControl(obj,true,true,false,true) ;

else if (iLen == 4)

e.Handled = true ;

break ;

case 45://-

e.Handled = true ;

break ;

case 8://backspace

case 27://esc

e.Handled = false ;

break ;

default :

e.Handled = true ;

break ;

}

}

private void tbMonth_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

{

if (this.DesignMode)

return ;

TextBox obj = (TextBox)sender ;

obj.SelectedText = "" ;

string strValue = obj.Text ;

int iLen= strValue.ToString().Length ;

int key = (int)(e.KeyChar) ;

switch(key)

{

case 48://0

case 49://1

case 50://2

case 51://3

case 52://4

case 53://5

case 54://6

case 55://7

case 56://8

case 57://9

if (iLen == 0)

e.Handled = false ;

else if (iLen == 1)//已经输入了一位

{

e.Handled = true ; //默认不处理,后面分析需要处理的情况

if (key==48)//现在输入的是0

{

if(obj.SelectionStart == 0)//插入

{

if (strValue != "0")//已经输入的不是0

e.Handled = false ;

}

else if (strValue == "1")//追加且已经输入了1

e.Handled = false ;

}

else//输入的是非0数字

{

if (strValue == "0")//已经输入了一个0

{

if (obj.SelectionStart == 0)//前面插入数字

{

if (key==49)//只能插入1

e.Handled = false ;

}

else

e.Handled = false ;

}

else if (strValue == "1")//已经输入了一个1

{

if (obj.SelectionStart == 0)//前面插入数字

{

if (key==49)//只能插入0,1(前面已处理了0的情况)

e.Handled = false ;

}

else if (key==49||key==50)//0,1,2

e.Handled = false ;

}

else if (strValue == "2")//已经输入了一个2

{

if (obj.SelectionStart == 0&&(key==49))//前面插入数字只能插入0,1

e.Handled = false ;

}

}

if (e.Handled == false)

obj.Parent.SelectNextControl(obj,true,true,false,true) ;

}

else

e.Handled = true ;

break ;

case 45://-

e.Handled = true ;

break ;

case 8://backspace

if (iLen == 0)

obj.Parent.SelectNextControl(obj,false,true,false,true) ;

break ;

case 27://esc

e.Handled = false ;

break ;

default :

e.Handled = true ;

break ;

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有