Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5993221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:38:39+00:00 2026-05-22T23:38:39+00:00

I am trying to pick only a time (hour and minutes) using propertygrid and

  • 0

I am trying to pick only a time (hour and minutes) using propertygrid and datetimepicker.
I have created my own editor.
The trouble is that it is not showing the value in the text and the value can also have calendars:

Here have code:

public class Tests
    {
        private DateTimePicker time = new DateTimePicker();

        [Editor(typeof(MyEditor), typeof(UITypeEditor))]
        public DateTimePicker Time
        {
            get { return time; }
            set { time = value; }

        }

        public Tests()
        {
            time.Format = DateTimePickerFormat.Time;
            time.CustomFormat = "hh:mm";
            time.Value = DateTime.Now;
            DateTime t = new DateTime();

        }

    }

    class MyEditor : UITypeEditor
    {

        IWindowsFormsEditorService editorService;
        DateTimePicker picker = new DateTimePicker();

        public MyEditor()
        {

            picker.Format = DateTimePickerFormat.Custom;
            picker.CustomFormat = "hh:mm";
            picker.ShowUpDown = true;
            picker.ValueChanged += new EventHandler(picker_ValueChanged);
        }

        void picker_ValueChanged(object sender, EventArgs e)
        {
            this.editorService.CloseDropDown();
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {

            if (provider != null)
            {
                this.editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            }

            if (this.editorService != null)
            {

                DateTimePicker tmp = (DateTimePicker)value;
                tmp.CustomFormat = "hh:mm";
                tmp.Text = tmp.Value.ToString();
                picker = tmp;

                this.editorService.DropDownControl(picker);

            }

            return value;

        }

        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.DropDown;
        }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:38:39+00:00Added an answer on May 22, 2026 at 11:38 pm

    I finally did it by using strings

    public class Tests {
      private string time;
    
      [Editor(typeof(TimePickerEditor), typeof(UITypeEditor))]
      public string Time {
        get { return time; }
        set { time = value; }
      }
    
      internal class TimePickerEditor : UITypeEditor {
        IWindowsFormsEditorService editorService;
        DateTimePicker picker = new DateTimePicker();
        string time;
    
        public TimePickerEditor() {
          picker.Format = DateTimePickerFormat.Custom;
          picker.CustomFormat = "mm:HH";
          picker.ShowUpDown = true;
        }
    
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) {
          if (provider != null) {
            this.editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
          }
          if (this.editorService != null) {
            if (value == null) {
              time = DateTime.Now.ToString("HH:mm");
            }
            this.editorService.DropDownControl(picker);
            value = picker.Value.ToString("HH:mm");
          }
          return value;
        }
    
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) {
          return UITypeEditorEditStyle.DropDown;
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIDatePicker that only has month, day, and year. I am trying
I'm trying to pick up Lua programming but I'm stuck on something that's probably
I'm trying to have the user pick an audio file and store the path
I am trying to use 'get_posts' to pick up posts that are in two
I am trying to get jquery to pick up variable that I am defining
I'm trying to run an Icecast stream using a simple Python script to pick
I'm trying to do something that sounds fairly simple using ASP.NET 3.5. A user
I'm trying to pick a web framework that is Java based to start a
I'm first time poster here trying to pick up some Python skills; please be
have been away from Android for more than a year, trying to pick up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.