最新下载
热门教程
- 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))
相关文章
- 阿里云企业邮箱官方入口在哪找-阿里云企业邮箱官网入口 02-12
- 火车票余票查询-火车票时刻表查询 02-12
- pokicon免费游戏畅玩-pokicon免费游戏一键直达 02-12
- 抖音充值-官方直充入口-家庭共享账户专享 02-12
- 磁力狗最新版本官网安装包下载-磁力狗引擎极速下载入口 02-12
- 嘀哩嘀哩无名小站怎么看-嘀哩嘀哩dilidili最新入口速递 02-12