Here we will see how to use the Numeric Format Specifier in LightSwitch Visual Studio 2012.
The numeric ("N" or "n") format specifier is used to convert a number into a string form as "-d,ddd,ddd.dd", where the "-" symbol indicates a negative number that is optional, "d" indicates a digit (from 0 to 9), "," indicates a group separator, and the "." symbol indicates a decimal point. The precision is used to indicate the desired number of digits after the decimal point.
Note: Number (N) is supported by all numeric data types.
Use the following procedure to create a sample showing how to use a Numeric Format Specifier 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.
Step 2
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, 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.
Step 4
Now stop debugging the application. From the Table Designer select the "Fees" record as shown in the figure below.
Then go to the Format Pattern of the Property window in the Table Designer and either enter "N" in the format pattern as shown below.
Or enter enter "n" in the format pattern as shown below.
Once again press F5 to run the application. This time we will get the following output.
We can also provide a negative value in the fees column.
Step 5
We can also provide an integer value. For providing an integer value go to the Table Designer and select the "Integer" data type for Fees.
Now go to the Format Pattern of the Property window in the Table Designer and enter "N" in the format pattern.
Now run the application. We will get the following output as shown below.