Share via


Visual Basic Concepts

Creating the MyDataControl Project

The MyDataControl control will be compiled into an .ocx file in a later step in this chapter, so it can be used in other projects. Thus the MyDataControl project will be created as an ActiveX control project.

Note   This topic is part of a series that walks you through creating sample data source components. It begins with the topic Creating Data Sources.

To create the MyDataControl project

  1. On the File menu, click New Project to open the New Project dialog box. (This will close your current project or project group; you will be prompted to save any changes you have made.) Double-click the ActiveX Control icon to create a new project.

    Visual Basic automatically adds a UserControl designer to the project. The default name, UserControl1, appears as the caption of the designer.

  2. On the Project menu, click Project1 Properties to open the Project Properties dialog box. In the General tab, fill out the information shown in the table below, and then click OK.

Property Setting
Project Name MyDataControl
Project Description ActiveX data source control demo.
  1. Double-click UserControl1 in the Project Explorer window to bring the designer to the front.

  2. In the Properties window, double-click the Name property and change the name of the user control to MyData. The new name appears in the title bar and in the Project Explorer window.

  3. In the Properties window, double-click the DataSourceBehavior property to change its value to 1 – vbDataSource. The DataSourceBehavior property allows the control to act as a data source; setting it also adds a GetDataMember event to the control.

  4. On the File menu, click Save Project to save the project files. Name them as shown in the following table. Visual Basic will provide the indicated extensions automatically.

File File name Extension
User control MyData .ctl
Project MyDataControl .vbp
Binary information in a control — such as bitmaps — will be saved in a binary file with the same name and an extension of .ctx.

For More Information   See "Setting Up a New Control Project and Test Project" and "Debugging Controls," in "Building ActiveX Controls."

Step by Step

This topic is part of a series that walks you through creating sample ActiveX data sources.

To See
Go to the next step Drawing the MyData Control
Start from the beginning Creating Data Sources