最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
可用来显示空值的时间选择控件5
时间:2022-07-02 11:53:12 编辑:袖梨 来源:一聚教程网
private void tbDay_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (this.DesignMode)
return ;
TextBox obj = (TextBox)sender ;
obj.SelectedText = "" ;
string strValue = obj.Text.Trim() ;
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||key==49||key==50)//现在输入的是0,1,2
{
if(obj.SelectionStart == 0)//插入
{
if (strValue != "0")//已经输入的不是0
e.Handled = false ;
if (strValue == "0" &&(key==49||key==50))
{
if (this.DesignMode)
return ;
TextBox obj = (TextBox)sender ;
obj.SelectedText = "" ;
string strValue = obj.Text.Trim() ;
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||key==49||key==50)//现在输入的是0,1,2
{
if(obj.SelectionStart == 0)//插入
{
if (strValue != "0")//已经输入的不是0
e.Handled = false ;
if (strValue == "0" &&(key==49||key==50))
相关文章
- 《职场浮生记》卡牌模组推荐 06-15
- 《纸嫁衣4红丝缠》全章节图文攻略 06-15
- 《这城有良田》奖率三军课业加点攻略 06-15
- 《纸嫁衣2奘铃村》全章节攻略汇总 06-15
- 《王者荣耀》夺宝保底次数介绍 06-15
- 《向僵尸开炮》百分比宝石选择推荐 06-15