Here we will see how to use a Group separator and Number Scaling Format Specifier in LightSwitch Visual Studio 2012.
The "," custom format specifier can be used as both a group separator and a number scaling specifier.
- Group Separator:
If multiple commas are specified between two digit placeholders (0 or #) the that formats the digits of that number. In a group separator, a comma is inserted between each number group as shown below in the output.
- Number Scaling Specifier
If one or more commas are specified immediately to the left of the digit, the number that is to be formatted is divided by 1000 for each comma. Suppose the specifier "0,," is used to format the number 100 million, the output will be "100".
Note: We can also use a group separator and number scaling specifier together in the same format specifier as shown below. The format specifier should only consist of the following symbols: #,0.
Use the following procedure to create a sample showing how to use a Group separator and Number scaling on a Screen.
Step 1
Open the LightSwitch Application in Visual Studio 2012 and go to the Solution Explorer.
Right-click on "Data Sources" and choose "Add Table".
The table appears in the table designer window. Insert the records in the following table.
Here in the table I have added a record named "Fees" and I used "Integer" as its datatype as shown below.
Step 2
Select the "Fees" record from the table and go to the Property window and provide "#,#" under Format Pattern TextBox.
Format Pattern in the Property window:
Now once again go to the Solution Explorer, right-click on Screens and choose "Add Screen".
The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template then inside the screen information, choose "Student" under screen data and provide some name to the Screen and click the "OK" button.
The Screen Designer appears as shown below.
Step 3
Press F5 to run the application. Provide the information.
Now click on the "save" button. We will get the following output as shown below.
Step 4
Now stop debugging the application and go to the Format Pattern of Property window in the table designer. This time enter "#,#,," in the format pattern of the Property window.
Once again press F5 to run the application. Provide the information.
Now click on the "save" button. We will get the following output as shown below.
Step 5
Now 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.
Once again press F5 to run the application. Provide the information.
Now click on the "Save" button. We will get the following output.
Step 6
This time the format specifier consists of the hash group separator and zero (#,0).
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.
Once again press F5 to run the application. Provide the information. Now click on the "Save" button. We will get the following output.