Decimal Format Pattern in LightSwitch 2012

Here we will see how to use format patterns for the Decimal datatype in LightSwitch Visual Studio 2012.

The format pattern for Decimals consists of the following three types of patterns:

  • Use "." to format a decimal value.
  • Use "+."  to format a positive decimal value.
  • Use "-." to format a negative decimal value.

The following is the procedure for creating a sample use of the Decimal Format Pattern 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

In the preceding table I have added a record named "Fees" and I have taken its datatype as "Decimal".

Select Fees From Table

Step 2

Select the "Fees" record from the table and go to the Property window and provide "
." (decimal) under the Format Pattern TextBox.

Decimal Point in Pattern Property

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 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.

Screen Designer

Step 3

Press F5 to run the application. Provide the information. 

Insert data in Output Screen

When we click on the "Save" button we get the following output where the decimal point disappears, as shown:

Output after saving data

Step 4

Stop debugging the application. Once again go to the Format Pattern of Property window in the table designer. This time enter "
+." (plus symbol along with decimal point) in the format pattern of the Property window. 

Positive Decimal Format Pattern

Once again press F5 to run the application. This time the 
result is that the number will be displayed with a positive symbol (+).

Output for Positive Decimal 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 "
-." (minus symbol along with decimal point) in the format pattern of the Property window.

Negative decimal Format Pattern Property

Once again press F5 to run the application. 
This time the result is that the number will be displayed with a negative symbol (-).

Output for Negative Decimal Format Pattern


Similar Articles