How to design a Windows Forms application

In the last chapter, you learned the basic skills for working with Visual Studio, you toured a Windows Forms application, and  you tested an application with three Windows forms. Now, in this chapter, you’ll learn how to use Visual Studio to design the  user interface for a Windows Forms application.

How to set options and create a new project

Before you start your first Windows Forms application with Visual Studio 2015, you probably should change a few of the Visual Studio options. That will make it easier for you to create a new project. You may also want to change the import and export settings.

How to set the Visual Studio options

To set the options for Visual Studio, you use the Options dialog box shown in figure 2-1. Once this dialog box is open, you can expand the Projects and Solutions group by clicking on the symbol to the left of that group, and you can click on the General group to display the options shown in this figure. You can set the default project location by typing a path directly into the text box, or you can click the button to the right of the text box to display a dialog box that lets you navigate to the folder you want to use. This will set the default location for new projects, but you can always override the default when you create a new project.

By default, most of the options available from this dialog box are set the way you want. However, it’s worth taking a few minutes to review the options that are available. Then, you can change them if Visual Studio isn’t working the way you want it to. For instance, you may want to use the Startup group within the Environment group to change what’s displayed when Visual Studio starts.

How to change the import and export settings

The first time you start Visual Studio 2015, you’re asked what Default Environment Settings you want to use. You can choose from several options including Visual Basic, Visual C#, Visual C++, and Web Development. Among other things, your choice affects what items are available from some menus and what buttons are available from the Standard toolbar. If, for example, you choose the Visual C# settings, you open a project with the File -> Open -> Project/Solution command. But if you choose the Visual Basic settings, you open a project with the File->Open Project command.

To change these settings, you use the Import and Export Settings Wizard as described in this figure. In the first step of the wizard, choose the Reset All Settings option. In the second step, choose the Yes, Save My Current Settings option. And in the last step, if you want your menus to work as described in this book, choose the Visual C# option. Later, if you switch to Visual Basic, C++, or web development, you can change the settings again.

How to use the Options dialog box

  • To display the Options dialog box, select the Tools->Options command.
  • To expand and collapse a group of options, you can use the relevant symbols to the left of each group. To display the options for a group, click on the group.
  • To set the default location for all projects that you start from Visual Studio, you can change the Projects Location as shown above.
  • If you want Visual Studio to work as described in this book, be sure that the Always Show Solution and Save New Projects When Created options are checked.
  • To change the color theme for Visual Studio, select the General category in the Environment group and then select an option from the Color Theme drop-down list.
  • Although most of the options should be set the way you want them, you may want to familiarize yourself with the options in each category so you know what’s available.

How to set the Import and Export Settings

• The first time you start Visual Studio 2015, you are asked to choose the default environment settings. These settings affect how the menus work and what buttons are displayed on the Standard toolbar.

• To change the settings to the ones used for this book, use the Tools->Import and Export Settings command to start the Settings Wizard. Then, choose the Reset All Settings option, the Save My Current Settings option, and the Visual C# Development Settings option as you step through the wizard.

This article is an excerpt from Murach C# 2015 by Anne Boehm and Joel Murach

Reproduced with permission from Murach Publishing

Leave a Comment