ComponentOne DateTimeEditors for WPF: DateTimeEditors for WPF Task-Based Help > C1TimeEditor Task-Based Help > Selecting the Time Format

Selecting the Time Format

By default, the C1TimeEditor control displays the time in a long format that includes seconds, but it can also display time in a shorter format or into a time span format. In this topic, you will learn how to change the time format in the designer, in XAML, and in code.

In the Designer

To change the time format, complete the following steps:

1.   Click the C1TimeEditor control once to select it.

2.   In the Properties window, click the Format drop-down arrow and select a mode from the list. For this example, select ShortTime.

In XAML

To change the time format, place Format="ShortTime" to the <my:C1TimeEditor> tag so that the markup resembles the following:

 

<my:C1TimeEditor Format="ShortTime">

In Code

To change the time format, complete the following steps:

1.   Open the Window1.xaml.cs page.

2.   Import the following namespace:

      Visual Basic

Imports C1.WPF.DateTimeEditors

      C#

using C1.WPF.DateTimeEditors;

3.   Place the following code beneath the InitializeComponent() method:

      Visual Basic

C1TimeEditor1.Format = C1TimeEditorFormat.ShortTime

      C#

c1TimeEditor1.Format = C1TimeEditorFormat.ShortTime;

4.   Run the project.

*This Topic Illustrates the Following:

In this topic, you set the Format to ShortTime, which provides a shortened time display. The final result will resemble the following image:

 


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.