Chapter 5: Passing Information between Windows

 

Bringing an Existing Project into the IDE for Further Work

When you are in the IDE screen and you click on the File entry in the main menu, you are offered the choice of creating a new project or loading an existing project. To load an existing project, follow these steps:

  1. Click on File and choose Open in the submenu list.

  2. You are given three choices: Project Solution, File, and Convert. If the project you are loading is already in version 2.0 (MSBuild) format, click on Project Solution .

There is no present use for the File option. But if the project you are attempting to load comes from an earlier version of Visual Studio C#, select Convert. As it turns out, if you select the Project Solution option and the project folder is not in MSBuild format (a C# version 1.0 or 1.1 format), then the IDE will perform the conversion to the current configuration anyway.

Project Folder Conversion Sequence (from v1.0 or 1.1 Projects)

If this project is already in version 2.0 MSBuild format, the project opens in the IDE. However, if this is a conversion from an earlier project folder format, then the window in Figure 3-12 will appear.

image from book
Figure 3-12: Visual Studio Conversion Wizard
  1. To move directly to completion (Figure 3-15), click on Finish . When you click on the Next > button to proceed, the window in Figure 3-13 appears.

    image from book
    Figure 3-13: Choosing backup files

  2. If you choose Yes, a backup file will be created. If you choose No, a backup is not created.

    Click Finish to move directly to Figure 3-15, or click Next > to continue with the conversion (see Figure 3-14).

    image from book
    Figure 3-14: Ready to Convert window

  3. After reviewing the summary information, click Finish to finish the conversion and proceed with the new MSBuild folder format. The window in Figure 3-15 appears.

    image from book
    Figure 3-15: Conversion Complete window

You will find that the files placed in this upgraded version of an old C# project differ slightly from those files that are created by a totally new project.

Once the conversion is complete, the IDE will open with the upgraded project. You can build and run this upgraded project in the same manner that any other C# project is built and run.

Confusing Filenames

You will soon discover that there are three important files that describe a form (window) in Visual Studio C# version 2.0:

  • FormX.Designer.cs

  • FormX.cs

  • FormX.cs[Design]

These can be confusing to work with as the names are so similar. Be careful when using these files.

When you ask to see the FormX.cs[Design] file, you are shown a graphical representation of a window (the window template). When you ask to see the FormX.cs file, source code is presented in the IDE.

The FormX.Designer.cs file, which is totally computer generated (a long list of the controls in the project), can only be seen if you choose File from the main menu followed by Open and then File. Then double-click on the FormX.Designer.cs file you want to see. You can also view this file in WordPad since the file is a text file.

Normally, it is not necessary that you view the FormX.Designer.cs file. But there is one notable exception to this rule. In Chapter 5, Passing Information between Windows , we will show you how to change a private class object into a public class object so child windows can write information to that public class object in the main window (and vice versa). It is not a complicated procedure, but we demonstrate the process so you can use it in the future.

All controls are initially created as private class objects by the IDE. The change process (private to public or public to private) is also an automated process because the programmer cannot manually perform the task without seriously damaging the bookkeeping processes within a project. We will explain this fully in Chapter 5.

This completes the overview of the Microsoft IDE.

 


Unlocking Microsoft C# V 2.0 Programming Secrets
Unlocking Microsoft C# V 2.0 Programming Secrets (Wordware Applications Library)
ISBN: 1556220979
EAN: 2147483647
Year: 2005
Pages: 129

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net