":" Custom Format Specifier in LightSwitch 2012

This article explains how to use the ":" Custom Format Specifier in LightSwitch Visual Studio 2012.

":" Custom Format Specifier

The ":" Custom Format Specifier provides a separator between hours, minutes and seconds. The time separator is received from the DateTimeFormatInfo.TimeSeparator property.

Note:
 If the ":" format specifier is used without any custom format specifier then it is considered to be a Standard Date Time Format Specifier and it will result in a Format Exception.

Use the following procedure to create a sample sample of using the ":" Custom Format Specifier on a Screen.

Step 1

Open the LightSwitch Application in Visual Studio 2012 and go to the Solution Explorer.

Solution Explorer

Right-click on "Data Sources" and choose "Add Table".

Add Table

The table appears in the Table Designer window. Insert the records in the following table.

Employee Table

Step 2

Now once again go to the Solution Explorer, right-click on "Screens" and choose "Add Screen".

Add Screen

The Add New Screen dialog box appears. Select "Editable Grid Screen" from the Screen Template, inside the screen information, choose "Employee" under the screen data and provide a name to the Screen and click the "OK" button.

Add New Screen

The Screen Designer appears as shown below.

Screen Designer

Press F5 to run the application. Provide the information; we will get the following output:

Output of Editable Grid Screen

Step 3

Now stop debugging the application. From the Table Designer select the "DOB" record as shown in the figure below.

Select DOB from Employee

Then go to the Format Pattern of the Property window in the Table Designer and enter "hh:mm" in the format pattern property as shown below.


Applying Time Separator in Format Specifier

Once again press F5 to run the application. This time we will get the following output.

Output using Time Separator

Step 4

Once again stop debugging the application and select the "DOB" record from the table and then go to the Format Pattern of Property window in the Table Designer and this time enter "mm:ss" in the format pattern property as shown below.


Format Pattern mm ss time separator

Once again press F5 to run the application. This time we will get the following output.

Output for mm ss time separator Format


Similar Articles