Dela via


Data Sources Window

The Data Sources window displays the data sources in your project. You can use the Data Sources window to create a user interface (consisting of data-bound controls) by dragging items from the window onto forms in your project. Each item has a drop-down control list where you can select the type of control to create prior to dragging it onto a form. You can customize the control list with additional controls, including controls that you have created.

Data Sources Window

Using the Data Sources window, you can:

Opening the Data Sources Window

You display the Data Sources window by clicking Show Data Sources on the Data menu. The Data menu is only available when a project is open in Visual Studio.

Populating the Data Sources Window

You populate the Data Sources window by adding data sources to your project. To add new data sources with the Data Source Configuration Wizard, click Add New Data Source on the Data menu or click the Add New Data Source link in the Data Sources window.

You can also populate the window by adding DataSet items to your project using the Dataset Designer. For more information, see the "To create a dataset with the Dataset Designer" section of How to: Create a Typed Dataset.

Creating Data-bound Controls

You can drag an item from the Data Sources window onto a form to create a new data-bound control, or you can drag an item from the Data Sources window onto an existing control to set up the data binding between the control and the item dragged onto it. Each node in the Data Sources window allows you to choose the type of control that will be created when you drag it onto a form. You must choose between a Grid layout, where all columns or properties are displayed in a DataGridView, or a Details layout, where all columns or properties are displayed in individual controls. You can choose the control to be created prior to dragging by selecting an item in the Data Sources window and choosing the control from the item's drop-down control list.

Data Sources Window showing relation

The Data Sources window displays related tables in a hierarchical tree view. For example, in a dataset with Customers and Orders tables (where a customer can have many orders), the Orders table appears as the last column in the Customers table as an expandable node. To display data from this related table and set up the data binding to display the related orders for a selected customer, you would drag items from this related tree view (as opposed to items from the individual top-level nodes for Customers and Orders). For more information, see How to: Display Related Data in a Windows Application.

Commands Available in the Data Sources Window

The following commands are available when you right-click the Data Sources window:

  • Add New Data Source
    Opens the Data Source Configuration Wizard, which assists you in creating new data sources in your project.

  • Edit DataSet with Designer
    Opens the selected dataset in the Dataset Designer. For more information, see How to: Edit a Dataset.

  • Configure DataSet with Wizard
    Opens the Data Source Configuration Wizard populated with information from the selected data source.

  • Refresh
    Synchronizes the Data Sources window with the data sources in your project.

Removing Data Sources from the Data Sources Window

The items in the Data Sources window are synchronized with your project, so removing an item from a project will be reflected in the Data Sources window. For example, if your project has a data source based on a Web service, removing the Web reference from your project also removes the Web service data source from the Data Sources window. For more information, see How to: Remove Data Sources from the Data Sources Window.

See Also

Tasks

How to: Set the Control to be Created when Dragging from the Data Sources Window

How to: Add Custom Controls to the Data Sources Window

Other Resources

Displaying Data on Forms in Windows Applications

Getting Started with Data Access

Connecting to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Editing Data in Your Application

Validating Data

Saving Data