KB Article T411714
Visible to All Users

How to view and edit only time values without the date part using the WinForms TimeEdit and ASP.NET WebForms ASPxTimeEdit components

Scenario
One may want to make a business property for storing and visualizing the event time only when the date part is not important (it can still be stored, though). For instance, this may be the check-in/check-out time for a worker or the session/exam start time:


Solutions
You can implement one of the following popular solutions that imply that your business class contains a property of the System.DateTime type:

1. Implement a custom Property Editor based on the WinForms TimeEdit and ASP.NET WebForms ASPxTimeEdit components. Review these help articles for more details:
Concepts > UI Construction > View Items > Implement Custom Property Editors
Task-Based Help > How to: Implement a Property Editor Using a DevExpress WinForms Control and DevExpress.ExpressApp.Win.Editors > DXPropertyEditor
WinForms Controls > DevExpress.XtraEditors > TimeEdit

Task-Based Help > How to: Implement a Property Editor Based on Custom Controls (ASP.NET) and DevExpress.ExpressApp.Web.Editors.ASPx > ASPxPropertyEditor
ASP.NET WebForms Controls> Data Editors > Editor Types > ASPxTimeEdit > ASPxTimeEdit Overview

Attached is a sample project showing a possible XAF integration of these components (see the DomainObject.cs, TimeEditPropertyEditor.cs and ASPxTimeEditPropertyEditor.cs files as well as the settings in the TimeEditIntegrationSample.Module.WXX\Model.DesignedDiffs.xafml files). Take special note that this is just an example, and you may require to further modify and test it according to your real business requirements.

OR

2. Customize the display format and edit mask settings for existing DateTime Property Editors:
Task-Based Help > How to: Customize a Built-in Property Editor (ASP.NET)
Task-Based Help > How to: Customize a Built-in Property Editor (WinForms)

3.  Technically, there can be alternative solutions with the System.String and System.TimeSpan properties and custom masks, but they are less common or natural. You can learn more about this from public community resources like StackOverFlow:
http://stackoverflow.com/a/29509668
http://stackoverflow.com/search?q=.net+store+time+without+date

See Also
Concepts > Business Model Design > Data Types Supported by built-in Editors
Concepts > UI Construction > Using a Custom Control that is not Integrated by Default

Search keywords: TimeEdit, ASPxTimeEdit, time part, AM, PM, without date, custom property editor

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.