Share via


How to: Add Class Diagrams to Projects (Class Designer)

You can begin designing, editing, and refactoring classes and other types in a Visual Studio project using Class Designer by adding a class diagram to the project. You can add blank class diagrams to your project, or you can create diagrams from existing types in your project. Each project can contain multiple class diagrams, useful for visualizing different code areas of the project.

To add a blank class diagram to a project

  1. In Solution Explorer, right-click the project name, and do one of the following:

    • Click Add New Item.

    • Point to Add, and click New Item.

    The Add New Item dialog box appears.

  2. In the templates pane of the Add New Item dialog box, perform one of the following:

    • To create a class diagram with the default name, double-click Class Diagram.

    • To create a class diagram with another name, click Class Diagram, change the name in the Name box, and click Add.

    The class diagram opens in Class Designer and appears as a file that has a .cd extension in Solution Explorer in the project hierarchy. The Class Designer toolbox appears. It contains shapes and lines that you can drag to the diagram.

  3. To add multiple class diagrams, repeat the steps in this procedure.

    Note

    You can also create class diagrams by clicking the Class Diagram button in Solution Explorer, or by clicking View Class Diagram from the context menus of Class and Project nodes in Solution Explorer and Namespace and Type nodes in Class View. Select the project node, a class file, or multi-select individual class files to create a class diagram based on the selected items.

To add a class diagram based on existing classes or types

  1. In Solution Explorer, select the file(s) that contain the items to display on the class diagram, Multi-selecting files is okay.

  2. Click the View Class Diagram button on the Solution Explorer toolbar.

  3. The class diagram opens in Class Designer and displays all classes and types in the selected files.

To add a class diagram based on an entire project

  1. In Solution Explorer, select the project name.

  2. Click the View Class Diagram button on the Solution Explorer toolbar.

  3. The class diagram opens in Class Designer and displays all classes and types in the project.

See Also

Tasks

How to: Create Types by using Class Designer

How to: View Existing Types (Class Designer)

Other Resources

Designing Classes and Types (Class Designer)

Viewing Types and Relationships (Class Designer)

Working with Class Diagrams (Class Designer)