Adding Items to the Diagram

You add items to the class designer by using either the Toolbox or the Solution Explorer. The Toolbox is for adding new items. You use the Solution Explorer to add existing classes to the diagram. In both scenarios, you simply drag and drop the item onto the class designer window. If the item already exists, Visual Studio builds out the class details for you. In fact, if the class file contains more than one class, each class is placed as an object on the diagram.

Figure 6.53 shows an example of the class designer Toolbox tools. Notice that you can define all object-oriented concepts here, including classes, interfaces, and inheritance.

Image

FIGURE 6.53 The class designer Toolbox.

When you add a new item such as a class or struct to the designer, the designer prompts you for the item’s name and location. You can choose to generate a new file to house the item or place it in an existing file. Figure 6.54 shows the New Class dialog box. Here, you can give the class a name, set its access modifier, and indicate a filename.

Image

FIGURE 6.54 Adding a new class to the class designer.


Tip

The class designer can automatically add related classes to the diagram. For example, suppose you add a class from the Solution Explorer. If you want to show classes that inherit from this class, you can right-click the class and choose Show Derived Classes. This adds to the model all classes that derive from the selected class.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset