"X" Hexadecimal Format in LightSwitch 2012

This article describes how to use the Hexadecimal Format Specifier in LightSwitch Visual Studio 2012.

The hexadecimal ("X") format specifier is used to convert a number to a string of hexadecimal digits. In the format specifier you can use uppercase or lowercase characters for the hexadecimal digits greater than 9. In other words, you can use either "X" to produce "ABCDEF", or "x" to produce "abcdef".

Note: This format specifier is supported only for integer data types.

Precision Specifier: the number of digits in the resultant string.
 According to the requirement, the number is padded with zeros to its left side to produce the number of digits provided by the precision specifier.

The following procedure describes how to create a sample showing how to use 
the Hexadecimal Format Specifier 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

Step 2

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 and click on the "save" button; we will get the following output:

Output of Editable Grid Screen

Step 4

Now stop debugging the application. From the Table designer select the "Fees" record as shown in the figure below.

Select fees from Student Table

Then go to the Format Pattern of the Property window in the table designer and enter 
"X" (in uppercase) in the format pattern as shown below. Or you can also enter "x" (in lower case) in the format pattern.

Format Pattern in Properties

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

X Format pattern output

Step 5

Now once again stop debugging the application then
go to the Format Pattern of the Property window in the table designer and enter "X4" (in uppercase) in the format pattern as shown below.

X4 pattern Properties

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

X4 format pattern output

If I put the value 10 inside the fees column then we have:

10 value in Fees

Now click on the "save" button; we will get the following output:

output for 10 value


Similar Articles