Click here to Skip to main content
12,702,599 members (33,026 online)
Click here to Skip to main content


66 bookmarked

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.Windows.Forms.Design
Imports System.Drawing.Design

Class TimeColorsUIEditor
    Inherits UITypeEditor

    ' Indicate that we display a modal dialog.
    Public Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle
        Return UITypeEditorEditStyle.Modal
    End Function

    ' Edit a Selected value.
    Public Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, _
        ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
        ' Get the editor service.
        Dim editor_service As IWindowsFormsEditorService = _
            CType(provider.GetService(GetType(IWindowsFormsEditorService)), _
        If editor_service Is Nothing Then Return value

        Dim dlg As dlgTimeColors = New dlgTimeColors

        ' Prepare the editing dialog.
        With dlg
            If context.Instance.GetType Is GetType(gTimePickerCntrl) Then
                Dim Instance As New gTimePickerCntrl
                Instance = CType(context.Instance, gTimePickerCntrl)
                .gTimePickerColors.TimeColors = Instance.TimeColors

                ' Display the dialog.

            ElseIf context.Instance.GetType Is GetType(gTimePicker) Then
                Dim Instance As New gTimePicker
                Instance = CType(context.Instance, gTimePicker)
                .gTimePickerColors.TimeColors = Instance.TimeColors

                ' Display the dialog.
                '    'This is needed if using in a SmartTag
                '    Instance = CType(context.Instance., gTimePickerCntrl)
            End If

        End With

        ' Return the new value.
        Return dlg.gTimePickerColors.TimeColors
    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.


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


About the Author

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
Web02 | 2.8.170118.1 | Last Updated 8 Feb 2012
Article Copyright 2009 by SSDiver2112
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid