Windows Forms Điều khiển và dữ liệu tài sản Binding Nhiều nhất Windows Các hình thức kiểm soát có thể được đính kèm, hoặc bị ràng buộc, với một nguồn dữ liệu. Sau khi họ bị ràng buộc, giá trị trong nguồn dữ liệu thay đổi giá trị tài sản bị ràng buộc và ngược lại. | Windows Forms Controls and Data Binding Many properties of most Windows Forms controls can be attached or bound to a data source. After they are bound the value in the data source changes the value of the bound property and vice versa. You have already seen data binding in action by using the TextBox and DataGridView controls in the DisplayProducts project in Chapter 23. The controls on the form were bound to BindingSource objects belonging to a DataSet containing records from the Suppliers and Products table in the database. Windows Forms controls support two types of data binding simple and complex. Simple data binding allows you to attach a property of a control or form to a single value in a data source and complex data binding is specifically used to attach a control to a list of values. Simple data binding is useful for controls such as TextBox or Label that only display a single value. Complex data binding is more commonly used with controls that can display multiple values such as ListBox ComboBox or DataGridView. Defining a DataSet and Using Simple Data Binding You use simple data binding to display a single value from a data source. A data source can be almost anything from a cell in a DataSet to the value of a property of another control to a simple variable. You can perform simple data binding at design time by using the Data-Bindings property of a control. In the exercises that follow you will define a new DataSet that defines a data source returning a single row and then bind the Text property of a Label control to a BindingSource object for this DataSet. Defining a DataSet class 1. In Visual Studio 2005 create a new project called ProductsMaintenance in the Microsoft Press Visual CSharp Step by Step Chapter 24 folder in your My Documents folder by using the Windows Application template. 2. In the Project menu click Add New Item. The Add New Item dialog box appears displaying templates for objects that can be added to a project. 3. In the Add New Item