Click here to Skip to main content
11,568,522 members (48,365 online)
Click here to Skip to main content
Add your own
alternative version

gTimePicker- Control to Pick a Time Value (VB.NET)

, 8 Feb 2012 CPOL 71.9K 2.5K 65
Stop using the DateTimePicker for time values. This control makes it easy to pick a time, and if you act now, get the matching Nullable gDateTimePicker at no extra cost.
Imports System.Windows.Forms.Design

<System.ComponentModel.ToolboxItem(False)> _
Public Class NullableDateTimeDropDown
    Private _editorService As IWindowsFormsEditorService = Nothing

    Private _Value As Nullable(Of DateTime)
    Public Property Value() As Nullable(Of DateTime)
        Get
            Return _Value
        End Get
        Set(ByVal value As Nullable(Of DateTime))
            _Value = value
            If _Value.HasValue Then MonthCalendar1.SetDate(CDate(_Value))
        End Set
    End Property

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        _Value = Nothing
        _editorService.CloseDropDown()

    End Sub

    Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
        _Value = MonthCalendar1.SelectionRange.Start
        _editorService.CloseDropDown()

    End Sub

    Public Sub New(ByVal value As Nullable(Of DateTime), ByVal editorService As IWindowsFormsEditorService)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        _editorService = editorService
        Me.Value = value
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

SSDiver2112
Software Developer
United States United States
I first got hooked on programing with the TI994A. After it finally lost all support I reluctantly moved to the Apple IIe. Thank You BeagleBros for getting me through. I wrote programs for my Scuba buisness during this time. Currently I am a Database manager and software developer. I started with VBA and VB6 and now having fun with VB.NET/WPF/C#...

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150624.2 | Last Updated 8 Feb 2012
Article Copyright 2009 by SSDiver2112
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid