Skip to content

Commit 0229699

Browse files
committed
Merge branch 'master' of github.com:MicrosoftDocs/visualstudio-docs-pr into tglee-vside
2 parents 8a84b15 + b9d267b commit 0229699

File tree

66 files changed

+785
-715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+785
-715
lines changed

docs/data-tools/TOC.md

Lines changed: 81 additions & 72 deletions
Large diffs are not rendered by default.

docs/data-tools/accessing-data-in-visual-studio.md

Lines changed: 32 additions & 40 deletions
Large diffs are not rendered by default.

docs/data-tools/add-code-to-datasets-in-n-tier-applications.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ ms.technology: "vs-data-tools"
2121
# Add code to datasets in n-tier applications
2222
You can extend the functionality of a dataset by creating a partial class file for the dataset and adding code to it (instead of adding code to the *DatasetName*.Dataset.Designer file). Partial classes enable code for a specific class to be divided among multiple physical files. For more information, see [Partial](/dotnet/visual-basic/language-reference/modifiers/partial) or [Partial Classes and Methods](/dotnet/csharp/programming-guide/classes-and-structs/partial-classes-and-methods).
2323

24-
The code that defines a dataset is generated every time changes are made to the dataset definition (in the typed dataset). This code is also generated when you make changes during the running of any wizard that modifies the configuration of a dataset. To prevent your code from being deleted during the regeneration of a dataset, add code to the dataset's partial class file.
24+
The code that defines a dataset is generated every time changes are made to the dataset definition (in the typed dataset). This code is also generated when you make changes during the running of any wizard that modifies the configuration of a dataset. To prevent your code from being deleted during the regeneration of a dataset, add code to the dataset's partial class file.
2525

26-
By default, after you separate the dataset and TableAdapter code, the result is a discrete class file in each project. The original project has a file named *DatasetName*.Designer.vb (or *DatasetName*.Designer.cs) that contains the TableAdapter code. The project that's designated in the **Dataset Project** property has a file that's named *DatasetName*.DataSet.Designer.vb (or *DatasetName*.DataSet.Designer.cs).This file contains the dataset code.
26+
By default, after you separate the dataset and TableAdapter code, the result is a discrete class file in each project. The original project has a file named *DatasetName*.Designer.vb (or *DatasetName*.Designer.cs) that contains the TableAdapter code. The project that's designated in the **Dataset Project** property has a file that's named *DatasetName*.DataSet.Designer.vb (or *DatasetName*.DataSet.Designer.cs).This file contains the dataset code.
2727

2828
> [!NOTE]
2929
> When you separate datasets and TableAdapters (by setting the **DataSet Project** property), existing partial dataset classes in the project won't be moved automatically. Existing dataset partial classes must be moved manually to the dataset project.
3030
3131
> [!NOTE]
3232
> When validation code needs to be added, the typed dataset provides functionality for generating <xref:System.Data.DataTable.ColumnChanging> and <xref:System.Data.DataTable.RowChanging> event handlers. For more information, see [Add validation to an n-tier dataset](../data-tools/add-validation-to-an-n-tier-dataset.md).
3333
34-
### To add code to datasets in n-tier applications
34+
## To add code to datasets in n-tier applications
3535

3636
1. Locate the project that contains the .xsd file.
3737

@@ -59,10 +59,9 @@ You can extend the functionality of a dataset by creating a partial class file f
5959
}
6060
```
6161

62-
## See Also
63-
[N-Tier Data Applications Overview](../data-tools/n-tier-data-applications-overview.md)
64-
[Add code to TableAdapters in n-tier applications](../data-tools/add-code-to-tableadapters-in-n-tier-applications.md)
65-
[Create and Configure TableAdapters](create-and-configure-tableadapters.md)
66-
[Create and Configure TableAdapters](create-and-configure-tableadapters.md)
67-
[Hierarchical Update Overview](hierarchical-update.md)
68-
[Dataset tools in Visual Studio](../data-tools/dataset-tools-in-visual-studio.md)
62+
## See also
63+
[N-Tier Data Applications Overview](../data-tools/n-tier-data-applications-overview.md)
64+
[Add code to TableAdapters in n-tier applications](../data-tools/add-code-to-tableadapters-in-n-tier-applications.md)
65+
[Create and Configure TableAdapters](create-and-configure-tableadapters.md)
66+
[Hierarchical Update Overview](hierarchical-update.md)
67+
[Dataset tools in Visual Studio](../data-tools/dataset-tools-in-visual-studio.md)

docs/data-tools/add-code-to-tableadapters-in-n-tier-applications.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ ms.technology: "vs-data-tools"
2222
# Add code to TableAdapters in n-tier applications
2323
You can extend the functionality of a TableAdapter by creating a partial class file for the TableAdapter and adding code to it (instead of adding code to the *DatasetName*.DataSet.Designer file). Partial classes enable code for a specific class to be divided among multiple physical files. For more information, see [Partial](/dotnet/visual-basic/language-reference/modifiers/partial) or [partial (Type)](/dotnet/csharp/language-reference/keywords/partial-type).
2424

25-
The code that defines a TableAdapter is generated every time changes are made to the TableAdapter in the dataset. This code is also generated when changes are made during the running of any wizard that modifies the configuration of the TableAdapter. To prevent your code from being deleted during the regeneration of a TableAdapter, add code to the partial class file of the TableAdapter.
25+
The code that defines a TableAdapter is generated every time changes are made to the TableAdapter in the dataset. This code is also generated when changes are made during the running of any wizard that modifies the configuration of the TableAdapter. To prevent your code from being deleted during the regeneration of a TableAdapter, add code to the partial class file of the TableAdapter.
2626

27-
By default, after you separate the dataset and TableAdapter code, the result is a discrete class file in each project. The original project has a file named *DatasetName*.Designer.vb (or *DatasetName*.Designer.cs) that contains the TableAdapter code. The project that's designated in the **Dataset Project** property has a file named *DatasetName*.DataSet.Designer.vb (or *DatasetName*.DataSet.Designer.cs) that contains the dataset code.
27+
By default, after you separate the dataset and TableAdapter code, the result is a discrete class file in each project. The original project has a file named *DatasetName*.Designer.vb (or *DatasetName*.Designer.cs) that contains the TableAdapter code. The project that's designated in the **Dataset Project** property has a file named *DatasetName*.DataSet.Designer.vb (or *DatasetName*.DataSet.Designer.cs) that contains the dataset code.
2828

2929
> [!NOTE]
3030
> When you separate datasets and TableAdapters (by setting the **DataSet Project** property), existing partial dataset classes in the project will not be moved automatically. Existing partial dataset classes must be moved manually to the dataset project.
@@ -34,7 +34,7 @@ You can extend the functionality of a TableAdapter by creating a partial class f
3434
3535
[!INCLUDE[note_settings_general](../data-tools/includes/note_settings_general_md.md)]
3636

37-
### To add user code to a TableAdapter in an n-tier application
37+
## To add user code to a TableAdapter in an n-tier application
3838

3939
1. Locate the project that contains the .xsd file.
4040

@@ -63,9 +63,8 @@ You can extend the functionality of a TableAdapter by creating a partial class f
6363
}
6464
```
6565

66-
## See Also
67-
[N-Tier Data Applications Overview](../data-tools/n-tier-data-applications-overview.md)
68-
[Add code to datasets in n-tier applications](../data-tools/add-code-to-datasets-in-n-tier-applications.md)
69-
[Create and Configure TableAdapters](create-and-configure-tableadapters.md)
70-
[Create and Configure TableAdapters](create-and-configure-tableadapters.md)
71-
[Hierarchical Update Overview](hierarchical-update.md)
66+
## See also
67+
[N-Tier Data Applications Overview](../data-tools/n-tier-data-applications-overview.md)
68+
[Add code to datasets in n-tier applications](../data-tools/add-code-to-datasets-in-n-tier-applications.md)
69+
[Create and Configure TableAdapters](create-and-configure-tableadapters.md)
70+
[Hierarchical Update Overview](hierarchical-update.md)

docs/data-tools/bind-controls-to-pictures-from-a-database.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ ms.technology: "vs-data-tools"
2525
# Bind controls to pictures from a database
2626
You can use the **Data Sources** window to bind an image in a database to a control in your application. For example, you can bind an image to an <xref:System.Windows.Controls.Image> control in a WPF application, or to a <xref:System.Windows.Forms.PictureBox> control in a Windows Forms application.
2727

28-
Pictures in a database are typically stored as byte arrays. Items in the **Data Sources** window that are stored as byte arrays have their control type set to **None** by default, because byte arrays can contain anything from a simple array of bytes to the executable file of a large application. To create a data-bound control for a byte array item in the **Data Sources** window that represents an image, you must select the control to create.
28+
Pictures in a database are typically stored as byte arrays. Items in the **Data Sources** window that are stored as byte arrays have their control type set to **None** by default, because byte arrays can contain anything from a simple array of bytes to the executable file of a large application. To create a data-bound control for a byte array item in the **Data Sources** window that represents an image, you must select the control to create.
2929

30-
The following procedure assumes that the **Data Sources** window is already populated with an item that is bound to your image.
30+
The following procedure assumes that the **Data Sources** window is already populated with an item that is bound to your image.
3131

3232
### To bind a picture in a database to a control
3333

@@ -43,5 +43,5 @@ You can use the **Data Sources** window to bind an image in a database to a cont
4343

4444
- Alternatively, you can select a different control that supports data binding and that can display images. If the control that you want to use is not in the list of available controls, you can add it to the list and then select it. For more information, see [Add custom controls to the Data Sources window](../data-tools/add-custom-controls-to-the-data-sources-window.md).
4545

46-
## See Also
47-
[Bind WPF controls to data in Visual Studio](../data-tools/bind-wpf-controls-to-data-in-visual-studio.md)
46+
## See also
47+
[Bind WPF controls to data in Visual Studio](../data-tools/bind-wpf-controls-to-data-in-visual-studio.md)
Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Bind Windows Forms controls to data in Visual Studio | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "11/03/2017"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.tgt_pltfrm: ""
@@ -23,48 +23,54 @@ manager: ghogen
2323
ms.technology: "vs-data-tools"
2424
---
2525
# Bind Windows Forms controls to data in Visual Studio
26-
You can display data to users of your application by binding data to Windows Forms. To create these data-bound controls, you can drag items from the **Data Sources** window onto the Windows Forms Designer in Visual Studio. This topic describes some of the most common tasks, tools, and classes involved in creating data-bound Windows Forms applications.
26+
You can display data to users of your application by binding data to Windows Forms. To create these data-bound controls, you can drag items from the **Data Sources** window onto the Windows Forms Designer in Visual Studio.
2727

28-
![Data Source drag operation](../data-tools/media/raddata-data-source-drag-operation.png "raddata Data Source drag operation")
28+
![Data Source drag operation](../data-tools/media/raddata-data-source-drag-operation.png "raddata Data Source drag operation")
29+
30+
Before you drag items, you can set the type of control you want to bind to. Different values appear depending on whether you choose the table itself, or an individual column. You can also set custom values. For a table, "Details" means that each column is bound to a separate control.
31+
32+
![Bind data source to DataGridView](../data-tools/media/raddata-bind-data-source-to-datagridview.png "raddata Bind data source to DataGridView")
2933

30-
For general information about how to create data-bound controls in Visual Studio, see [Bind controls to data in Visual Studio](../data-tools/bind-controls-to-data-in-visual-studio.md). For more information about data binding in Windows Forms, see [Windows Forms Data Binding](/dotnet/framework/winforms/windows-forms-data-binding).
34+
## BindingSource and BindingNavigator Controls
35+
The <xref:System.Windows.Forms.BindingSource> component serves two purposes. First, it provides a layer of abstraction when binding the controls to data. Controls on the form are bound to the <xref:System.Windows.Forms.BindingSource> component instead of directly to a data source. Second, it can manage a collection of objects. Adding a type to the <xref:System.Windows.Forms.BindingSource> creates a list of that type.
3136

32-
## In this section
37+
For more information about the <xref:System.Windows.Forms.BindingSource> component, see:
3338

34-
- [Bind Windows Forms controls to data](../data-tools/bind-windows-forms-controls-to-data.md)
39+
- [BindingSource Component](/dotnet/framework/winforms/controls/bindingsource-component)
3540

36-
- [Commit in-process edits on data-bound controls before saving data](../data-tools/commit-in-process-edits-on-data-bound-controls-before-saving-data.md)
41+
- [BindingSource Component Overview](/dotnet/framework/winforms/controls/bindingsource-component-overview)
3742

38-
- [Create lookup tables in Windows Forms applications](../data-tools/create-lookup-tables-in-windows-forms-applications.md)
43+
- [BindingSource Component Architecture](/dotnet/framework/winforms/controls/bindingsource-component-architecture)
3944

40-
- [Create a Windows Form to search data](../data-tools/create-a-windows-form-to-search-data.md)
45+
The [BindingNavigator control](/dotnet/framework/winforms/controls/bindingnavigator-control-windows-forms) provides a user interface for navigating through data displayed by a Windows application.
46+
47+
## Bind to data in a DataGridView control
48+
For a [DataGridView control](/dotnet/framework/winforms/controls/datagridview-control-overview-windows-forms), the entire table is bound to that single control. When you drag a DataGridView to the form, a tool strip for navigating records (<xref:System.Windows.Forms.BindingNavigator>) also appears. A [DataSet](../data-tools/dataset-tools-in-visual-studio.md), [TableAdapter](../data-tools/create-and-configure-tableadapters.md), <xref:System.Windows.Forms.BindingSource>, and <xref:System.Windows.Forms.BindingNavigator> appear in the component tray. In the following illustration, a TableAdapterManager is also added because the Customers table has a relation to the Orders table. These variables are all declared in the auto-generated code as private members in the form class. The auto-generated code for filling the DataGridView is located in the form_load event handler. The code for saving the data to update the database is located in the Save event handler for the BindingNavigator. You can move or modify this code as needed.
4149

42-
- [Create a Windows Forms user control that supports simple data binding](../data-tools/create-a-windows-forms-user-control-that-supports-simple-data-binding.md)
50+
![GridView with BindingNavigator](../data-tools/media/raddata-gridview-with-bindingnavigator.png "raddata GridView with BindingNavigator")
4351

44-
- [Create a Windows Forms user control that supports complex data binding](../data-tools/create-a-windows-forms-user-control-that-supports-complex-data-binding.md)
52+
You can customize the behavior of the DataGridView and the BindingNavigator by clicking on the smart tag in the upper right corner of each:
4553

46-
- [Create a Windows Forms user control that supports lookup data binding](../data-tools/create-a-windows-forms-user-control-that-supports-lookup-data-binding.md)
54+
![DataGridView and Binding Navigator smart tags](../data-tools/media/raddata-datagridview-and-binding-navigator-smart-tags.png "raddata DataGridView and Binding Navigator smart tags")
4755

48-
- [Pass data between forms](../data-tools/pass-data-between-forms.md)
56+
If the controls your application needs are not available from within the **Data Sources** window, you can add controls. For more information, see [Add custom controls to the Data Sources window](../data-tools/add-custom-controls-to-the-data-sources-window.md).
4957

50-
## BindingSource component
51-
The <xref:System.Windows.Forms.BindingSource> component serves two purposes. First, it provides a layer of abstraction when binding the controls on your form to data. Controls on the form are bound to the <xref:System.Windows.Forms.BindingSource> component (instead of being bound directly to a data source).
58+
You can also drag items from the **Data Sources** window onto controls already on a form to bind the control to data. A control that is already bound to data has its data bindings reset to the item most recently dragged onto it. To be valid drop targets, controls must be capable of displaying the underlying data type of the item dragged onto it from the **Data Sources** window. For example, it's not valid to drag an item that has a data type of <xref:System.DateTime> onto a <xref:System.Windows.Forms.CheckBox>, because the <xref:System.Windows.Forms.CheckBox> is not capable of displaying a date.
5259

53-
Second, it can manage a collection of objects. Adding a type to the <xref:System.Windows.Forms.BindingSource> creates a list of that type.
60+
## Bind to data in individual controls
61+
When you bind a data source to "Details," each column in the dataset is bound to a separate control.
5462

55-
For more information about the <xref:System.Windows.Forms.BindingSource> component, see:
63+
![Bind data source to details](../data-tools/media/raddata-bind-data-source-to-details.png "raddata Bind data source to details")
5664

57-
- [BindingSource Component](/dotnet/framework/winforms/controls/bindingsource-component)
65+
> [!IMPORTANT]
66+
> Note that in the previous illustration, you drag from the Orders property of the Customers table, not from the Orders table. By binding to the Customer.Orders property, navigation commands made in the DataGridView are reflected immediately in the details controls. If you dragged from the Orders table, the controls would still be bound to the dataset, but not they would not be synchronized with the DataGridView.
5867
59-
- [BindingSource Component Overview](/dotnet/framework/winforms/controls/bindingsource-component-overview)
60-
61-
- [BindingSource Component Architecture](/dotnet/framework/winforms/controls/bindingsource-component-architecture)
68+
The following illustration shows the default data-bound controls that are added to the form after the Orders property in the Customers table is bound to "Details" in the **Data Sources** window.
6269

63-
## BindingNavigator control
64-
This component provides a user interface for navigating through data displayed by a Windows application. For more information, see [BindingNavigator Control](/dotnet/framework/winforms/controls/bindingnavigator-control-windows-forms).
70+
![Orders table bound to details](../data-tools/media/raddata-orders-table-bound-to-details.png "raddata Orders table bound to details")
6571

66-
## DataGridView control
67-
To display and edit tabular data from many different kinds of data sources, use the <xref:System.Windows.Forms.DataGridView> control. You can bind data to a <xref:System.Windows.Forms.DataGridView> by using the <xref:System.Windows.Forms.DataGridView.DataSource%2A> property. For more information, see [DataGridView Control Overview](/dotnet/framework/winforms/controls/datagridview-control-overview-windows-forms).
72+
Note also that each control has a smart tag. This tag enables customizations that apply to that control only.
6873

69-
## See Also
70-
[Bind controls to data in Visual Studio](../data-tools/bind-controls-to-data-in-visual-studio.md)
74+
## See also
75+
[Binding controls to data in Visual Studio](../data-tools/bind-controls-to-data-in-visual-studio.md)
76+
[Data binding in Windows Forms (.NET Framework)](/dotnet/framework/winforms/windows-forms-data-binding)

0 commit comments

Comments
 (0)