Note that there are some explanatory texts on larger screens.

plurals
  1. POChoose time using datetimepicker in propertygrid
    primarykey
    data
    text
    <p>I am trying to pick only a time (hour and minutes) using <code>propertygrid</code> and <code>datetimepicker</code>.<br> I have created my own editor.<br> The trouble is that it is not showing the value in the text and the value can also have calendars:</p> <p>Here have code:</p> <pre><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; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload