This article describes how to use the General ("G") Format Specifier in LightSwitch Visual Studio 2012.The general ("G") format specifier converts a number, either in fixed-point or in scientific notation depending on what the type is of the number and whether a precision specifier is present. The precision specifier determines the maximum number of significant digits that can appear in the resultant string.Fixed-point notation is always used whenever the exponent in scientific notation is greater than -5 and less than the precision specifier; otherwise, scientific notation is used. The result contains a decimal point on the basis of requirements, and trailing zeros after the decimal point are omitted. If the precision specifier is present and the number of significant digits in the result exceeds the specified precision then the excess trailing digits are removed by rounding. If the number is decimal and the precision specifier is omitted then fixed point notation is always used and trailing zeros will remain preserved.Use the following procedure to create a sample showing how to use the General("G") Format Specifier on a Screen.Step 1Open 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 2Now 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 screen information, choose "Employee" under screen data and provide some name to the Screen and click the "OK" button.The Screen Designer appears as shown below.Step 3Press F5 to run the application. Provide the information. Step 4Now stop debugging the application. From the Table Designer select the "Salary" record as shown in the figure below.Then go to the Format Pattern of the Property window in the Table Designer and enter "G" in the format pattern as shown below.Or you can enter enter "g" in the format pattern as shown below.Once again press F5 to run the application. This time we will get the following output.Step 5In the following step the digits of a number will be rounded.Once again, stop debugging the application. From the Table Designer select the "Salary" record as shown in the figure below.Then go to the Format Pattern of the Property window in the Table Designer and enter "G4" in the format pattern as shown below.Once again press F5 order to run the application. Provide the information.This time we will get the following output. In the output the number will be rounded.Step 6In this step I will be using a number in exponential form as shown below.Go to the Format Pattern of the Property window in the Table Designer and enter "G" in the format pattern as shown below.Once again press F5 to run the application. Provide the following information.Click on the "Save" button and this time we will get the following output.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: