On 12 August, 2013 07:00:03,
by Dirk Strauss
Visual Studio LightSwitch – If I had to ask you to write an application that just needs to record basic member details (Name, Last Name, Telephone, Address and Image), how long do you think that will take you to do? Can you give me a ball park figure on the time it will take? What about 30 minutes?
Well Visual Studio LightSwitch is one of the most incredible technologies available to developers. If you need to create highly customizable data driven forms, Visual Studio LightSwitch is the way to go.
The Visual Studio LightSwitch community is a large one, and is made up of some really awesome people too numerous to mention. But there are a few that I do want to introduce you too. Here are your wingmen and women. Be sure to bookmark their blogs, add them to your RSS feed and follow them on social media.
Jan Van der Haegen
Jan is the reason I started with LightSwitch. I wanted to learn something new, and decided to try my hand at LightSwitch. I reached out to Jan on Social Media and the guy was really awesome. He provided me with a wealth of information and helped me jump start my Visual Studio LightSwitch journey. It also helped that Jan wrote an awesome book for the Syncfusion Succinctly series on LightSwitch. The best of all is that it is totally free! You have NO reason not to get this resource. In fact, I will go as far as saying that as a beginner, this book is all that you need to get you going. Trust me, get the book. While you’re at it, check out Jan’s blog.
Beth shares some really awesome content on her blog. Sharing the goodness is her motto and it is easy to see why. The gems she shares about Visual Studio LightSwitch will propel your LightSwitch skills to a totally new level. In her own words:
I’m a Senior Program Manager on the Visual Studio team at Microsoft and a community champion for business application developers. Before Microsoft, I spent 15 years building business apps for small businesses as well as large enterprises. I am a frequent speaker at various software development events and you can find me on a variety of developer sites including MSDN.com, Channel 9, and my blog www.bethmassi.com. Follow me on twitter @BethMassi
I have always enjoyed the content she shares, and I am certain you will too.
Michael is another guy you can count on to deliver superb LightSwitch content. His website is crammed with excellent tips and chances are that you will find a solution to any LightSwitch issue you face on his site. Also be sure to connect with Michael on Twitter.
Visual Studio LightSwitch: Jump Start
At time of writing this article, the time was 16:13. I’m just putting that out there for you to remember. Right, let us start. Fire up Visual Studio 2012 and create a new Visual Studio LightSwitch project.
Visual Studio LightSwitch now prompts you to start with data. This is because data is what drives LightSwitch. Go ahead and click on the ‘Create new table’ link.
The table designer will be displayed. If you are familiar with SQL Server, this will be old hat for you. If not, don’t worry. It’s really not that difficult. In the properties screen to the right, you can modify the table properties. I renamed my table to Member.
You can now go ahead and add some additional fields to you data table. You can add whatever you need in here. You will notice that you don’t have to define field lengths etc.
After you have added these fields to the table, you will notice that there is a row of menu items across the top of the screen.
Easy enough, click on ‘Screen’.
This will allow you to add and associate a screen with your newly created data table. A nice screen to start with is the list and details screen.
In the menu on the right, add the Members table to your screen and also keep the Member Details check box checked.
Clicking on Ok will display the form designer. All you do now is click on F5 to Run your snazzy Visual Studio LightSwitch project.
Initially it will take a while to build and display your form, but when it is running, this is what you will see. A fully data aware form that you can add data to. The time is 16:15. Yes, I did time myself. From clicking on the Create New Visual Studio LightSwitch project to seeing this Windows Form took 2 minutes. Isn’t that incredible? When I first started programming, this simple form would take much, much longer than 2 minutes to create. So let us see what our shiny new form can do.
Visual Studio LightSwitch: Form Features
Your new form comes with some awesome features, which are fully functional, straight out of the box, without you doing anything extra. So let us go ahead and add a new member.
Fill in the member details and add an image to your form. You will remember that we added the image field to our table above.
Clicking on Ok will add the member details you your form. You will notice that the member isn’t saved yet. You can continue to add members or click save.
The save button at the bottom of the screen allows you to save all the data in your current screen.
We can now add more members as we need. The form will display them in a list to you and allow you to navigate between them.
Lastly (for this post anyway), your form allows you to Add, Edit, Delete, Export your form data to Excel (yes, you read that right), order your list items and search your list right there from within your form.
It is really clear from this short post that the potential Visual Studio LightSwitch has for rapid application development is vast. You can generate some really nice looking forms very easily. You can also add ‘skins’ that make your form look totally different. This article has only scratched the surface of what is possible with Visual Studio LightSwitch. Don’t be fooled by it’s simplicity. It is highly customizable and you can do as much with LightSwitch in code as what you can with a regular Windows Form.
Go and have a look at some of the excellent resources mentioned above. Reach out and connect with the community. Get involved and get your hands dirty with Visual Studio LightSwitch.
Dirk is a Software Developer and Microsoft MVP from South Africa. He loves all things Technology and is slightly addicted to Twitter and Jimi Hendrix. Apart from writing code, he also enjoys writing human readable articles. "I love sharing knowledge and connecting with people from around the world. It's the diversity that makes life so beautiful." Dirk feels very strongly that pizza is simply not complete without Tabasco, that you can never have too much garlic, and that cooking the perfect steak is an art he has yet to master.