SYSK 154: Adding Existing Classes to a Class Diagram

There is plethora of articles describing how cool is the class diagramming functionality, available in most (Standard and up) editions of Visual Studio 2005.  “The Visual Studio Class Designer lets you visualize the structure of classes and other types, and through these visual representations edit their source code. Changes made to the class diagram are immediately reflected in code, and changes made to the code immediately affect the appearance of the designer. This synchronous relationship between designer and code makes it easy to create and configure complex CLR types visually” (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/clssdsgnr.asp for more info).

 

And using it is a snap – just right-click the class you want to create a diagram for in the Solution Explorer, and select View Class Diagram. 

 

But if you want to add a class, all the ‘Add Class’ functionality I came across adds a new class.  So, how can you add an existing class to a desired class diagram?  The answer is simple: the old friend, ‘drag-and-drop’ will do the job – just click on the class you want to add from class view to an existing class diagram, and you’ve got it!