Custom Search in LightSwitch 2012

In this article you will learn how to make a custom search in LightSwitch 2012.

Getting Started

  1. Open Visual Studio 2012.
  2. Go to "File" => "New" => "Project..."
  3. Select "LightSwitch" in installed templates.
  4. Select "LightSwitch Application (Visual C#)".
  5. Enter the Name and choose the location.
  6. Click "OK".

The next step is to add data sources or add tables. After that add a new query after right-clicking on the data source.


Image 1.

Now add a filter condition and add a select columns name and add new parameters.


Image 2.

As you can see, a query has been added to the selected data source.


Image 3.

Now add a new screen and select screen data and select that query name.


Image 4.

As you can see, a filter parameter has been added, you can also edit the query.


Image 5.

Hit F5 to see the result.


Image 6.

As you can see, the search text box is empty and it's mandatory, if you enter a contact name then that will show the result, let's do a little more exited.

Go to the properties of the screen designer and click on the search column and go to "Properties".


Image 7.

Click on the "Choice List" link button.


Image 8.

Add a few values and display name and click "OK".

Now run the project.


Image 9.

As you can see all choices are loading a search text box, now choose one contact name to see the result.


Image 10.