Click here to Skip to main content
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
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.ComponentModel
Imports System.Drawing.Design
Imports System.Windows.Forms.Design

Public Class NullableDateTimeTypeEditor
    Inherits UITypeEditor

    ' Indicate that we display a dropdown.
    Public Overrides Function GetEditStyle( _
        ByVal context As System.ComponentModel.ITypeDescriptorContext) _
        As System.Drawing.Design.UITypeEditorEditStyle

        Return UITypeEditorEditStyle.DropDown
    End Function

    Public Overrides Function EditValue( _
        ByVal context As System.ComponentModel.ITypeDescriptorContext, _
        ByVal provider As System.IServiceProvider, ByVal value As Object) As Object

        ' Get an IWindowsFormsEditorService object.
        Dim editor_service As IWindowsFormsEditorService = _
            CType(provider.GetService(GetType(IWindowsFormsEditorService)), _
            IWindowsFormsEditorService)
        If editor_service Is Nothing Then
            Return MyBase.EditValue(context, provider, value)
        End If

        ' Pass the UI editor the current property value
        Dim Instance As New gDateTimePicker
        If context.Instance.GetType Is GetType(gDateTimePicker) Then
            Instance = CType(context.Instance, gDateTimePicker)
        End If

        ' Make the editing control.
        Dim editor_control As New NullableDateTimeDropDown(Instance.gValue, editor_service)
        ' Display the editing control.
        editor_service.DropDownControl(editor_control)

        ' Save the new results.
        Return editor_control.Value
    End Function

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

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