The easiest way to create business applications for the Desktop and the Cloud
One of the new LightSwitch features in the Visual Studio 2013 Preview is the ability to import a list of name/value pairs to the Choice List dialog from either a file or from another Choice List. This is useful when you have a long list of values that you need to add (for example: List of US states), in which you can simply copy and paste them to the Choice List.
This feature will allow you to:
Now let’s start with some examples. Let’s say you are creating a simple application that stores sales orders. For every sales order, you need to track its status:
You keep the list of options for this status property in an Excel file since it’s easier to enter, edit and sort in Excel:
To use those values, select the status property and click on “Choice List” from the Property window to open the Choice List Dialog.
Go back to the Excel file you have, select the values and copy them to Clipboard
Now go back to the Choice List dialog and right-click on the edge of the grid and select the Paste command to paste the values. Make sure not to right-click on the cell, otherwise you’ll get the context menu of the cell which is different than the context menu of the Choice List grid.
As you can see LightSwitch treated the first column that was copied from Excel as the value for the Value column, and the second column from Excel as the value for the Display Name column.
Tip: Your copied list doesn’t have to provide all the values for the Display Name. If the 2nd column is blank, the Choice List will use the Value for the Display Name.
Press Ok and Hit F5 and there you have it.
Now after you test the application you realized that you still missing some values and you need to add them to the list, what should you do? You could simply copy the values from the Excel file and paste them to the Choice List in the position you want. Here is the list from Excel file with the new items
You select the new items and copy them
You go to the Choice List diagram and highlight the row you want to insert the new items after. Paste the values from Clipboard by either choosing the Paste command from the context menu or by pressing Ctrl+V.
If you want to insert the new items in another position (Before the “Paid” item), you simply right-click on the edge of the grid next to the Paid item and select Paste command from the context menu
Now let’s say that you have a new requirement that is to add a status for the Sales Order Items too, and the status values are same as the status values for the Sales Order Header entity except for few items. What should you do? You could simply select the items from the existing Choice List that you have and copy them to the Choice List of the order details.
Here is how you can do it:
Open the Choice List dialog that you created before and select the items you want.
Right-click and select the Copy command from the context menu or press Ctrl+C.
Go to the other Choice List and you want to copy the items too and right-click the mouse and select the Paste command from the context menu:
So that was one of the helpful features you could do in Visual Studio 2013 Preview. Let us know on the forums how you’re using this feature or if you run into any problems.
Amr Altahlawi, LightSwitch SDE
Technorati Tags: VS2013,Choice List
Please, create the custom control grid color and custom control upload/download files.
Ricardo - thanks for the feedback! We'll definitely take this into consideration for future releases. If you have any other feedback just post to the forums ( social.msdn.microsoft.com/.../home ) or send me mail directly (peter.hauge @ microsoft.com ). Thanks!
It would be interesting in the code behind an enumerator was created with items from the list of choices.
Who can tell how to fill in the Choice List of tables MS SQL?
Thanks for the post. This is something we've considered. Unfortunately, it hasn't yet made our priority list. You can create a request on UserVoice connect.microsoft.com/lightswitch which we regularly review for suggestions.
Are you looking for the choice list to be populated with the list of tables in the database?
Стив Ласкер-MS - Yes
a table would be preferable (client rather than programmer can maintain) and also adjust for local preferences).
and if this choice list can do multi select it would just be a dream come true.
ie: pack;ship is result of selecting both options.
I am with SlotDB! It seems odd that ChoiceList cannot easily be bound to data from a table in SQL.
Then the user can add something to table via an Add/Ediyt scrren and the list is updated dynamically for them.
I do realize there is ways around this, however LightSwitch is supposed to ease development.... so...lets make it easy!?
@Bret, @SlotDB -- You can DEFINITELY define a lookup table, set up a relation, and then (boom) LS will automatically generate a modal pick list for your screen that is completely data driven. Choice lists are good for STATIC values (i.e. Yes/No, Male/Female, etc). You definitely should use lookup tables in LightSwitch for dynamic choices. See: msdn.microsoft.com/.../ff961882.aspx
I'm Munna Kumar Sah
Thanks For share . Its very usefull for me because this Article instruct to step by step.
Thanks a lot for above Tip.... it saved me loads of time.. absolutely loved it !!