I have a table with the Field gender that I would like to turn into a custom control (Edit:ComboBox) with fields of Male and Female. Relatively new to Lightswitch and I am not sure how to go about doing that aspect. I have tried looking but couldn't find any information. I am using the 2012RC. Thanks
-
why a custom control? will it be anything more than a dropdown list with two options? – Glenn Ferrie Jul 20 '12 at 01:47
-
No, But then How would I do it then? I thought picking a ComboBox and Populating it was the best way – Mike Diaz Jul 20 '12 at 01:57
1 Answers
There are four ways to create an autocomplete box:
- Foreign Key Constraint
- Local Property
- Local Variable
- Choice List
There's a good blog post describing how to accomplish this goal through the methods described above.
For your specific scenario, I would recommend using a foreign key constraint to ensure data integrity is never violated in or outside of the LightSwitch application. All you need to do is create a foreign key constraint between the gender field in your data table and the primary key of a gender lookup table and you import both tables under the same data source. LightSwitch will automatically create this field as a combo box in data grids and detail forms. If you have multiple text fields in your gender lookup table, it will return the first string field as the displayed value by default. You can override this to select another field to display by updating the Summary Property in the gender lookup table.
Regarding terminology, drop down boxes are called autocomplete boxes in LightSwitch, so Googling for LightSwitch autocomplete will return several good articles and videos on how to create multi-column autocompletes, autocompletes with embedded images, sorting autocomplete boxes, filtering the available displayed values (such as filtering to current active products), using autocomplete boxes to filter other forms, etc.

- 8,357
- 8
- 49
- 65