Community-Credit.com | NonProfitWays.com | SOAPitstop.com   Skin:   
      User: Not logged in 
Home
Newsletter Signup
XSLT Library
Latest XML Blogs
Featured Examples
Presentations
Featured Articles
Book Chapters
Training Courses
Events
NewsGroups
 
Discussions
Examples
Tutorials
Tools
Articles
Resources
Websites
 
Sign In
My Profile
My Articles
My Examples
My Favorites
My Resources
Add a Resource
Logout
 
About Me
My Blog
HeadGeek Articles
Talking Portfolio
Resume
Pictures
World Trip Pics

Winforms DateTime picker with NULL binding support
Author: Duray AKAR
Published: 3/17/2006 12:09 PM
Category: ADO.NET, C#
Summary: The winforms datetimepicker control does not support null binding by default. so I had to create my own

 

Here is an example of a bindable DateTimePicker with NULL binding support.

It is just a fw lines of code, so no need to download... Just copy and paste. ;)

Hope it helps

 

Duray AKAR

 

    public class DateTimePickerNullable: System.Windows.Forms.DateTimePicker, INotifyPropertyChanged
    {
        public DateTimePickerNullable()
            : base()
        {
            ShowCheckBox = true;
        }

        [Bindable(true)]
        public Nullable<DateTime> BindableValue
        {
            get
            {
                if (Checked)
                {
                    return Value;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if (value.HasValue && value.Value > DateTime.MinValue)
                {
                    this.Checked = true;
                }
                else
                {
                    this.Checked = false;
                }
            }
        }

        public new bool Checked
        {
            get { return base.Checked; }
            set
            {
                base.Checked = value;
                OnPropertyChanged("BindableValue");
            }
        }

        protected override void OnCloseUp(EventArgs eventargs)
        {
            base.OnCloseUp(eventargs);
            OnPropertyChanged("BindableValue");
        }


        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged!=null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 
            }
        }

        #endregion
    }


 

 
Fans of "The Office"
Dwight Bobbleheads are here!

  “It's me! I'm the bobblehead! Yes!”



Advertise on XMLPitstop

Advertise on XMLPitstop


EggHead Cafe
Web Servicee development
DotNetSlackers
HP Printer Ink Cartridges
conference calls
online fax
conference call
chicago web design
Alojamiento Web
Web Hosting
Security Camera
brand names sunglasses
Video Surveillance
VoIP Internettelefonie

4,176 Total Members
5 members(last 30 days)
3 members(last 7 days)
0 members(today)

1,948 Total Discussions
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

47,487 Total Blog Posts
0 Blogs(last 30 days)
0 Blogs(last 7 days)
0 Blogs(today)

8,699 Newsgroup Posts
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

14,140 Total Resources
0 Resources(last 30 days)
0 Resources(last 7 days)
0 Resources(today)


 

David Silverlight's XMLPitstop.com| 2801 Florida Ave #225|Miami, FL 33133|Ph:305-447-1139