Format Pattern For Integer Data Type in LightSwitch 2012

This article describes how to use Format Patterns for the Integer datatype in LightSwitch Visual Studio 2012.

The Format Pattern for Integers consists of the following three types of patterns:

  • Use "+#" to format a positive value.
  • Use "+#" to format a positive value.
  • Use "0" if you do not want to change the value.

The following is the procedure to use an Integer 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 into the following table.

Student Table

In the preceding table I added a record named "Fees" and I used "Integer" for the datatype.

Step 2

Select the "Fees" record from the table and go to the Property window and provide "+#" under the Format Pattern TextBox.

Select Fees From Student Table

Submit +# Format Pattern

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. 
The result is that the number will be displayed with a positive symbol(+).

output for Positive integer

Step 4

Stop debugging the application.

Once again go to the Format Pattern of Property window in the table designer. This time enter "-#" in the format pattern of the Property window.

Submit -# in Format Pattern

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 Integer

Step 5

Stop debugging the application.

Once again go to the Format Pattern of Property window in the table designer. This time enter "0" in the format pattern of the Property window.

Submit 0 in Format Pattern

Once again press F5 run the application. This time we will get the same output, in other words there is no change in the output.

Output for Same Result

Step 6

Stop debugging the application.

Once again go to the Format Pattern of Property window in the table designer. This time enter "No Change" in the format pattern of the Property window.

Submit No Change String in Format Pattern

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

Output for No Change

NOTE: The text "No change" can work with or without quotes since there are no special formatting patterns for Integers. The quote can even be single quotes. 


Similar Articles