Visual Studio Hints and Tips for the Classroom

Setting up Visual Studio to Make Saving Projects Easier

By default Visual Studio 2005 does not ask the developer for a location to save their project. This is by design and it lets you easily discard a project when you are done with it. This is actually quite useful when you are writing a quick piece of code for a demo or to try something out. After all, just how many copies of “Hello World” do you really want to have on your computer? And is “WindowsApplication123” really something you want to save until the end of time? Probably not.

This works out very well for professional devotes. They are disciplined people (well, mostly) who are quite capable of saving their projects with a good name, in the right location, at the right time. Students? Well, quite frankly students are not always the best managers of their time. Many is the time I have seen a student save their project in a rush because the bell just rang and their next class is at the other end of the building. Sometimes it becomes almost impossible to find the project later. I always used to recommend that students save everything once the project was started. Sometimes they listened.

An other option is to force people to select a name and location for the project at creation time. That is the setting I recommend for student computers. This is how to do it.

From the Tools menu select Options. On the option dialogue box select Projects and Solutions and under that select General. Now check the option box labeled “Save new projects when created.” That will cause a full dialogue box to open when a new project is created so that students can easily specify the right location for their project. You can also change the default project location from this dialogue box. If every student’s account maps to their own drive you could use that address here.

One other suggestion: The Tools menu has an Import and Export Settings option. Once you get a set of settings that you think are perfect for use in your class you can export those setting to a file and use that file to a) set up other computers in the lab or b) put things back the way you want them after some student changes their settings in such a masterful way that Visual Studio becomes less usable by others.

Code Demonstration Hints and Tips

Visual Studio has had a number of features that make doing demonstrations easier for several versions. But almost every time I see a demo I am reminded that not everyone knows about them. These features include code snippets (about which I will talk in a future blog entry) and features that make it easier for others to read the code being demonstrated.

Often the most useful thing you can do for a code demo is the make the letters larger. Modern LSD projectors have come a long way and do a great job of projecting your monitor on to a screen. But some people are going to have trouble reading smaller print. There are an amazing number of students who don’t know that they need glasses and who set too far in the back of the room. Fortunately there is an easy situation to take care of.

From the Tools menu select options. The first option, Environment, has a line for Fonts and Colors. The dropdown box allows you to select various parts of the IDE and set their font size, style, color and just about anything else you want. I generally like to change the font size of the Text Editor to a 12 to 16 point font depending on the size of the room. This generally takes care of most “the font is too small” issues that come up.

Larger fonts do take up more room of course. So if I am focusing on the code I often take the Text Editor into full screen mode. This means that the other parts of the IDE are hidden but that I have a lot more room to show the code. I use keyboard shortcuts to make this change. The “magic” sequence is Shift-Alt-Enter. By pressing those three keys I can send the Text Editor into or back out of Full Screen mode.

One other thing I like to do when doing a demo is to move the various boxes (Toolbox, Properties Box, Solution Explorer) to the center of the window. This is easily done by double-clicking on the title bar of the box. This undocks the box and lets me move it around. I can increase the size of the box to show more options as well. When I am done I just double-click on the title bar again and the box snaps back to his previous docked location.

Don’t forget that the Tools menu has an Import and Export Settings option. You can save several sets of settings and import the one you want for various uses. Since I generally just change the font I don’t find that I need to use this that often but I do have a file with my favorite settings saved in case I get carried away sometime.

 

Formatting Shortcuts

 

From the Edit menu there is an option called Advanced that shows a number of helpful formatting options. One of the options I have found particularly useful is commenting and uncommenting a blog of code. If you highlight a block of code the key sequence Control K and Control C at the same time the whole block of code will be commented. Likewise if you highlight a block of commented code and use the key sequence Control K and Control U the block will be uncommented.

Normally code is automatically formatted as it is entered but this is not always the case. If you have a block of code that is not formatted nicely (perhaps something handed in by a student) you can have Visual Studio format the code for you. The Control K Control F sequence will format a block that has been selected. The Control K Control D sequence will format the whole document. I often found that formatting unformatted code made it a lot easier for me to review it and even to find logic issues.

 

Using the Visual Studio Class Designer

One of the really exciting new features of Visual Studio 2005 is the Class Designer. The Class Designer allows the programmer to quickly and easily set up the basic structure of a new class using a graphical interface. Using the Class Designer you name fields, properties, methods and events that make up a class. Fo each item you can specify the data types and parameters involved. The code will be created automatically. Not only that but if you add code in the code window and add, for example, a new field it will show up in the Class Designer window automatically.

To use the Class Designer select a class from from the Solution Explorer or from the Class View window and click on the View Class Diagram icon  from the icon menu. You can also right click on a class and select iew Class Diagram from the drop down menu. When you open the Class Designer you will open the Class Diagram from and the Class Details form (at the bottom of the IDE). Click on add method, add property, add field or add event to add an item to your class. Type in a new name and then add values for the type, modifier and summary information which will show up in the comments. Click on the plus sign next to a named item to open up a new line for parameters.

It's all really easy to use but easier to show than to describe. For that reason I have created a 7 and a half minute demo of this on the MainFunction website that you can watch if you'd like.

Comments

  • Anonymous
    April 30, 2006
    If you haven't added Alfred Thompson's blog to your RSS feed list, you should. He is the K-12 Computer...