zoukankan
html css js c++ java
用于处理DBNull问题的DateTimePicker
08/5/3改进版,请大家给些建议.谢谢!
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Windows.Forms;
using
System.ComponentModel;
using
System.Text.RegularExpressions;
namespace
WinUI
{
/**/
///
<summary>
///
用于处理DBNull问题的DateTimePicker
///
</summary>
public
class
MDateTimePicker :DateTimePicker
{
public
object
Value
{
get
{
return
base
.Value;
}
set
{
try
{
DateTime dt
=
Convert.ToDateTime(value);
base
.Value
=
dt;
}
catch
(Exception ex)
{
base
.Value
=
MaxDate;
;
}
}
}
protected
override
void
OnTextChanged(EventArgs e)
{
base
.OnTextChanged(e);
if
(Convert.ToDateTime(Value)
==
MaxDate)
{
Format
=
DateTimePickerFormat.Custom;
CustomFormat
=
"
"
;
}
else
{
Format
=
DateTimePickerFormat.Long;
}
}
protected
override
void
OnClick(EventArgs e)
{
base
.OnClick(e);
onEdit();
}
protected
override
void
OnKeyDown(KeyEventArgs e)
{
base
.OnKeyDown(e);
if
(e.KeyCode
==
Keys.Delete)
{
this
.Value
=
MaxDate;
}
else
{
onEdit();
}
}
private
void
onEdit()
{
Format
=
DateTimePickerFormat.Long;
Value
=
DateTime.Now;
}
}
}
---------------------------------------------------------------------
每个人都是一座山.世上最难攀越的山,其实是自己.往上走,即便一小步,也有新高度
.
--做最好的自己,我能!!!
查看全文
相关阅读:
SQL 2008 死锁进程查看。
[读书]35前要掌握的66种基本能力第10、11节
[读书]35前要掌握的66种基本能力第13、14节
[读书]35前要掌握的66种基本能力第8节
[读书]35前要掌握的66种基本能力第15、16、17、18节
近日小节
[读书]35前要掌握的66种基本能力第26、27、28、29节
C# aspx 数据绑定集中(待修改)
[读书]35前要掌握的66种基本能力第6节
[读书]35前要掌握的66种基本能力第9节
原文地址:https://www.cnblogs.com/tonyepaper/p/1180107.html
最新文章
web.xml配置jspfile例子
HTTPS重定向到HTTP
Ipad cydia常用的deb插件
整理文件比较的Shell脚本
项目中用的带宽估算方法
银行柜面授权整理
集成环境注意事项小结
Ipad越狱注意事项
HttpServletRequest几个常用方法的区别
获取用户真实IP地址问题
热门文章
maven packaging打包类型
为什么Spring Boot项目引入依赖的时候可以不指定依赖的版本号
什么是Lombok?
sql中错误使用EXISTS语法
IDEA隐藏不想看到的文件或文件夹
Spring注解@component、@service、@Autowired等作用与区别
java后台http请求方式
解决idea Spring Configuration Check 和application context not configured for this file问题
[读书]35前要掌握的66种基本能力第19、20、21、22节
[读书]35前要掌握的66种基本能力第23、24、25节
Copyright © 2011-2022 走看看