Standard Numeric Format Strings in LightSwitch 2012

This article describes how to use Standard Numeric Format Strings in LightSwitch Visual Studio 2012.

Standard Numeric Format Strings are used to format various Numeric Types. A standard numeric format string must be present in the form "Axx", where "A" is a letter called the Format Specifier and "xx" is an integer called the precision specifier. The specific range of precision specifier is from 0 to 99 and also affects the number of digits in the result. 

The following is the procedure for creating a sample showing how to use
Standard Numeric Format Strings 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.

Student Table

Here in the table I added a record named "TutionFees" and I used the datatype "Decimal" for it as shown below.

Step 2

Select the "TutionFees" record from the table and go to the Property window and provide "P" under the Format Pattern TextBox.
The result is Number multiplied by 100 and displayed with a percent symbol.

Select TutionFees

Format Pattern in Property window

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 the "Editable Grid Screen" from the Screen Template, inside the screen information, choose "Student" under screen data and provide some name to the Screen and click the "OK" button.

Add New Screen

The Screen Designer appears as shown below.

Application Designer

Step 3

Press F5 to run the application. Provide the information. 

Output Of P format Pattern

Step 4

Stop debugging the application.

Once again, go to the Format Pattern of the Property window in the table designer. This time enter "F" in the format pattern of the Property window. Here "F" represents Fixed Point.

F Format pattern in Property Window

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

output for F  Format pattern

Step 5

Stop debugging the application.

Once again go to the Format Pattern of Property window in the table designer. This time enter "F4" in the format pattern of Property window. Here 4 represent 4 digits will be there after the decimal places.

F4 in Format Pattern Property Window

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

F4 Format Pattern Output

Step 6

Stop debugging the application.

Once again go to the Format Pattern of Property window in the table designer. This time enter "E" in the format pattern of Property window. Here E represent Exponential Notation.

E format pattern in Property Window

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

E format Pattern Output

For other such 
Standard Numeric Format Strings follow Standard Numeric Format String