How to: Customize class diagrams
Applies to: Visual Studio Visual Studio for Mac
Note
This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
You can change the way that class diagrams display information. You can customize the whole diagram or the individual types on the design surface.
For example, you can adjust the zoom level of an entire class diagram, change how individual type members are grouped and sorted, hide or show relationships, and move individual or sets of types anywhere on the diagram.
Note
Customizing the way that shapes appear on the diagram doesn't change the underlying code for the types represented on the diagram.
The sections that contain type members, such as the Properties section in a class, are called compartments. You can hide or show individual compartments and type members.
Zoom in and out of the class diagram
Open and select a class diagram file in Class Designer.
On the Class Designer toolbar, click the Zoom In or Zoom Out button to change the zoom level of the designer surface.
or
Specify a particular zoom value. You can use the Zoom drop down list or type a valid zoom level (valid range is between 10% and 400%).
Note
Changing the zoom level does not affect the scale of your class diagram printout.
Customize grouping and sorting of type members
Open and select a class diagram file in Class Designer.
Right-click an empty area on the design surface and point to Group Members.
Select one of the available options:
Group by Kind separates individual type members into a grouped list of Properties, Methods, Events, and Fields. The individual groups depend on the entities definition: for example, a class will not display any events group if there are no events yet defined for that class.
Group by Access separates individual type members into a grouped list based on the member's access modifiers. For example, Public and Private.
Sort Alphabetically displays the items that make up an entity as a single alphabetized list. The list is sorted in ascending order.
Hide compartments on a type
Open and select a class diagram file in the Class Designer.
Right click the member category in the type you want to customize (for example, select the Methods node in a class.
Click Hide Compartment.
The selected compartment disappears from the type container.
Hide individual members on a type
Open and select a class diagram file in Class Designer.
Right-click the member in the type you want to hide.
Click Hide.
The selected member disappears from the type container.
Show hidden compartments and members on a type
Open and select a class diagram file in Class Designer.
Right-click the name of the type with the hidden compartment.
Click Show All Members.
All hidden compartments and members appear in the type container.
Hide relationships
Open and select a class diagram file in Class Designer.
Right-click the association or inheritance line that you want to hide.
Click Hide for association lines, and click Hide Inheritance Line for inheritance lines.
Click Show All Members.
All hidden compartments and members appear in the type container.
Show hidden relationships
Open and select a class diagram file in Class Designer.
Right-click the type with the hidden association or inheritance.
Click Show All Members for association lines, and click Show Base Class or Show Derived Classes for inheritance lines.
Remove a shape from a class diagram
You can remove a type shape from the class diagram without affecting the type's underlying code. Removing type shapes from a class diagram affects only that diagram: the underlying code that defines the type and other diagrams that display the type are not affected.
On the class diagram, select the type shape you want to remove from the diagram.
On the Edit menu, choose Remove from Diagram.
The type shape and any lines of association or inheritance connected to the shape no longer appear on the diagram.
Delete a type shape and its underlying code
Right-click the shape on the design surface.
Select Delete Code from the context menu.
The shape is removed from the diagram and its underlying code is deleted from the project.