可以解决DateTimePicker 无法为DBNull的代码.已经测试通过,收藏
转自 http://www.codeguru.com/csharp/csharp/cs_controls/custom/article.php/c9645/
using System;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
// Copyright (c) 2005 Claudio Grazioli, http://www.grazioli.ch
//
// This implementation of a nullable DateTimePicker is a new implementation
// from scratch, but it is based on ideas I took from this nullable
// DateTimePickers:
// - http://www.omnitalented.com/Blog/PermaLink,guid,9ee757fe-a3e8-46f7-ad04-ef7070934dc8.aspx
// from Alexander Shirshov
// - http://www.codeproject.com/cs/miscctrl/Nullable_DateTimePicker.asp
// from Pham Minh Tri
//
// This code is free software; you can redistribute it and/or modify it.
// However, this header must remain intact and unchanged. Additional
// information may be appended after this header. Publications based on
// this code must also include an appropriate reference.
//
// This code is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
//
namespace ProjectMentor.Windows.Controls
{
/// <summary>
/// Represents a Windows date time picker control. It enhances the .NET standard <b>DateTimePicker</b>
/// control with a ReadOnly mode as well as with the possibility to show empty values (null values).
/// </summary>
[ComVisible(false)]
public class NullableDateTimePicker : System.Windows.Forms.DateTimePicker
{
Member variables
Constructor
Public properties
Private methods/properties
OnXXXX()
}
}
using System.ComponentModel;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
// Copyright (c) 2005 Claudio Grazioli, http://www.grazioli.ch
//
// This implementation of a nullable DateTimePicker is a new implementation
// from scratch, but it is based on ideas I took from this nullable
// DateTimePickers:
// - http://www.omnitalented.com/Blog/PermaLink,guid,9ee757fe-a3e8-46f7-ad04-ef7070934dc8.aspx
// from Alexander Shirshov
// - http://www.codeproject.com/cs/miscctrl/Nullable_DateTimePicker.asp
// from Pham Minh Tri
//
// This code is free software; you can redistribute it and/or modify it.
// However, this header must remain intact and unchanged. Additional
// information may be appended after this header. Publications based on
// this code must also include an appropriate reference.
//
// This code is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
//
namespace ProjectMentor.Windows.Controls
{
/// <summary>
/// Represents a Windows date time picker control. It enhances the .NET standard <b>DateTimePicker</b>
/// control with a ReadOnly mode as well as with the possibility to show empty values (null values).
/// </summary>
[ComVisible(false)]
public class NullableDateTimePicker : System.Windows.Forms.DateTimePicker
{
Member variables
Constructor
Public properties
Private methods/properties
OnXXXX()
}
}
---------------------------------------------------------------------
每个人都是一座山.世上最难攀越的山,其实是自己.往上走,即便一小步,也有新高度.
每个人都是一座山.世上最难攀越的山,其实是自己.往上走,即便一小步,也有新高度.
--做最好的自己,我能!!!