Share via


How to: Create Types by using Class Designer

Using Class Designer, you can visually create new types on the class diagram by dragging them from the Class Designer toolbox onto a class diagram. To learn how to display existing types on a class diagram, see How to: View Existing Types (Class Designer).

Note

For detailed information on how to configure Inheritance and Association items by using Class Designer, see How to: Define Inheritance Between Types (Class Designer) and How to: Define Associations Between Types (Class Designer)

To create a Class or an Abstract Class by using Class Designer

  1. From the Class Designer toolbox, drag a Class or an Abstract Class item onto a class diagram.

    The New Class or New Abstract Class dialog box appears.

  2. Type the class name in the name text box.

  3. Select the access level of the class from the Access drop-down list.

  4. In the File name area, select which file the Class Designer should generate code into:

    • Select Create new file and type a filename in the text box, to create a new class file and add it to the current project.

    • Select Add to existing file to generate the classes code into an existing class file. To select an existing file, click the ellipsis () button next to the Add to existing file box.

  5. Click OK to create the class and generate the initial code into the file specified in the dialog box.

  6. Add the methods, properties, fields, events, constructors (method), destructors (method), and constants that define the class. For more information, see How to: Create a Member (Class Designer).

To create an Enum by using Class Designer

  1. From the Class Designer toolbox, drag an Enum item onto a class diagram.

    The New Enum dialog box appears.

  2. Type the enum name in the Enum name text box.

  3. Select the access level of the enum from the Access drop-down list.

  4. In the File name area select which file the Class Designer should generate code into:

    • Select Create new file and type a filename in the text box, to create a new class file and add it to the current project.

    • Select Add to existing file to generate the classes code into an existing class file. To select an existing file, click the ellipsis () button next to the Add to existing file box.

  5. Click OK to create the enum and generate the initial code into the file specified in the dialog box.

  6. Add the field values that make up the enumeration. For more information, see How to: Create a Member (Class Designer).

To create an Interface by using Class Designer

  1. From the Class Designer toolbox, drag an Interface item onto a class diagram.

    The New Interface dialog box appears.

  2. Type the interface name in the Interface name text box.

  3. Select the access level of the interface from the Access drop-down list.

  4. In the File name area select which file the Class Designer should generate code into:

    • Select Create new file and type a filename in the text box, to create a new class file and add it to the current project.

    • Select Add to existing file to generate the classes code into an existing class file. To select an existing file, click the ellipsis () button next to the Add to existing file box.

  5. Click OK to create the interface and generate the initial code into the file specified in the dialog box.

  6. Add the Methods, Properties, and Events that make up the Interface. For more information, see How to: Create a Member (Class Designer).

To create a Structure (Struct in C#) by using Class Designer

  1. From the Class Designer toolbox, drag a Structure item onto a class diagram.

    The New Structure dialog box appears.

  2. Type a name for the structure in the Structure name text box.

  3. Select the access level of the structure from the Access drop-down list.

  4. In the File name area select which file the Class Designer should generate code into:

    • Select Create new file and type a filename in the text box, to create a new class file and add it to the current project.

    • Select Add to existing file to generate the classes code into an existing class file. To select an existing file, click the ellipsis () button next to the Add to existing file box.

  5. Click OK to create the structure and generate the initial code into the file specified in the dialog box.

  6. Add the methods, properties, fields, events, constructors (method), destructors (method), and constants that define the structure. For more information, see How to: Create a Member (Class Designer).

To create a Delegate by using Class Designer

  1. From the Class Designer toolbox, drag a Delegate item onto a class diagram.

    The New Delegate dialog box appears.

  2. Type a name for the delegate in the Delegate name text box.

  3. Select the access level of the delegate from the Access drop-down list.

  4. In the File name area select which file the Class Designer should generate code into:

    • Select Create new file and type a filename in the text box, to create a new class file and add it to the current project.

    • Select Add to existing file to generate the classes code into an existing class file. To select an existing file, click the ellipsis () button next to the Add to existing file box.

  5. Click OK to create the delegate and generate the initial code into the file specified in the dialog box.

  6. Add the parameters that define the delegate. For more information, see How to: Create a Member (Class Designer).

To create a Module by using Class Designer (VB Only)

  1. From the Class Designer toolbox, drag a Module item onto a class diagram.

    The New Module dialog box appears.

  2. Type a name for the module in the Module name text box.

  3. Select the access level of the module from the Access drop-down list.

  4. In the File name area select which file the Class Designer should generate code into:

    • Select Create new file and type a filename in the text box, to create a new class file and add it to the current project.

    • Select Add to existing file to generate the classes code into an existing class file. To select an existing file, click the ellipsis () button next to the Add to existing file box.

  5. Click OK to create the module and generate the initial code into the file specified in the dialog box.

  6. Add the methods, properties, fields, events, constructors (method), and constants that define the module. For more information, see How to: Create a Member (Class Designer).

See Also

Tasks

How to: Define Inheritance Between Types (Class Designer)

How to: Define Associations Between Types (Class Designer)

Other Resources

Creating and Configuring Type Members (Class Designer)

Working with Class Diagrams (Class Designer)

Designing Classes and Types (Class Designer)