"E" and "e" Custom Format Specifier in LightSwitch 2012

Here we will see how to use Exponential Notation in LightSwitch Visual Studio 2012.

If any of the Exponential Notation Format Specifiers are present in the string and are followed immediately by at least one zero, then the number is formatted using scientific notation with an "E" or "e" that is inserted between the number and the exponent. The multiple number of zeros following the scientific notation represent the minimum number of digits to output for the exponent.

The "E+" and "e+" formats indicate that a plus sign or minus sign should always precede the exponent. The "E", "E-", "e", or "e-" formats indicate that a sign character should precede only negative exponents.


Use the following procedure to create a sample showing how to use Exponential Notation 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

Here in the table I had added a record named "Fees" and I provided its datatype as "Double".

Step 2

Select the "Fees" record from the table and go to the Property window and provide "E0" in the Format Pattern TextBox. 

Select Fees from Student

The Format Pattern Property Window:

E0 Format Pattern Property window

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. 

output showing editable grid screen

When we click on the "Save" button we get the following output as shown.

Output for format Pattern E0

Step 4

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

E+0 format pattern property window

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

Output for E+0 format pattern

Step 5

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

E-0 format pattern Property window

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

output for E-0 format Pattern

Step 6

Now for the remaining steps we will see the "e" Custom Format Specifier.

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

e0 format in Properties

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

Output for e0 format pattern

Step 7

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

e+0 pattern properties

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

Output for pattern e+0

Step 8

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

e-0 pattern in properties

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

e-0 output pattern

Up Next
    Ebook Download
    View all
    Learn
    View all