Creating And Removing Choice List Using Visual Studio LightSwitch 2012

Introduction

This article describes how to create a list of values for any particular field using LightSwitch Visual Studio 2012.

Choice List in LightSwitch

We develop a "Choice List" so that users can easily choose a value from a given set instead of entering a value into a text box on its own.

Creating a Choice List

Step 1

Open the Solution Explorer.

Image 1

solex.jpg

Step 2

In the Solution Explorer, select the table and open it.

Image 2

tab.jpg

Step 3

The table opens in the Data Designer.

Image 3

1Table.jpg

Step 4

Select a field from the table. Suppose I choose the "PinCode" field from the table.

Image 4

1Table2.jpg

Step 5

Open the properties window.

Image 5

prop.jpg

Step 6

In the properties window, choose the "Choice List" link. A Choice List dialog box will shown that consists of "Add Value" and "Display Name" header.

Image 6

choicelist.jpg

Step 7

In the Choice List table choose the "Add Value" option and enter the Value.

Image 7

value.jpg

Step 8

Similarly from the table choose "Display Name", and then enter the Name.

Image 8

Name.jpg

Step 9

We can add as many value as we want in the Choice List table.

Image 9

chlist.jpg

Step 10

Choose the "OK" button to close the Dialog Box. Now the Choice List is created successfully.

Removing a Choice List

First we will perform the following steps: Step 1, Step 2 and Step 3 in a similar manner as I have performed above to create the Choice List.

Step 1

As the table opens, select the field that uses a Choice List.

Image 1

1Table2.jpg

Step 2

Open the "Property" window.

Image 2

prop1.jpg

Select the "X" option that is shown next to the Choice List link. As the user clicks on it a dialog box will appear.

Image 3

del.jpg

Choose the "Yes" option to remove the Choice List.


Similar Articles