Control Types of a Field in LightSwitch 2012

Here we will see how to change the control type of a specific record in LightSwitch Visual Studio 2012.

Procedure showing how to change the control type of specific field

Step 1

Open the LightSwitch Application in Visual Studio 2012 and go to the Solution Explorer.

Solution Explorer

Right-click on the Data Source 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

I have also inserted a record named IsPresent in the table that is of Boolean type.

Step 3

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 "Editable Grid Screen" from the Screen Templates, under screen information, choose "Student" under the screen data and provide a name to the Screen and click the "OK" button.

Add New Screen

The Screen Designer appears. Under the "Data Grid Row" | "Student" , there is an IsPresent field whose control type is Checkbox by default.

Screen Designer

Step 4

Press F5 to run the application. We will see that the checkbox will appear under the "IsPresent" column as shown below

Screen output consisting of Checkbox

Step 5

Stop debugging the application.

In the Screen Designer, select the "IsPresent" field under the "Data Grid Row" | "Student" and then go to the property window and change the control type from "Checkbox" to "TextBox" as shown below.

Select IsPresent Field

Select Textbox from Control Type

There is another way by which we can change the control type, which is to open the
Screen Designer, select the "IsPresent" field under the "Data Grid Row" | "Student", a drop down list will appear from which we can easily select the control type as shown below.

Textbox Control Type from Screen Designer

Once again press F5 to run the application. 
We will see that the TextBox will appear under the "IsPresent" column as shown below.

Screen Output containing Textbox control type

Up Next
    Ebook Download
    View all
    Learn
    View all