1. Create a Windows Form project from vs2010.
2. Add a class named “Student” with two public properties, Name(string) and Id(int).
3. Build project.
4. Add a DataSource to this project, you can use the option from Toolbar or just right click on this project and select add a item option.
5. Select “Object” in the “Choose a Data Source Type” in the “Data Source Configuration Wizard”.
6. Check the “Student” type which we add in to this project before.
7. After those steps, you will see “Student.datasource” in the “Properties->DataSources”.
Ok, now, our data source added to the project successfully.
8. Open the “Data Source” tab, you will see the Student data source is existing, then you just can drag it onto the Form, VS2010 will create a DataGridView with the “BindingNavigator”.
Now, we had finished to bind the Object to the DataGridView.
Then we will go on to bind the Object’s Property to a TextBox.
9. Open the “Formatting and Advanced Binding” window by click on the “…” button in the “(Advanced)” row.
Then choose a property for binding to the TextBox from “Binding” ComboBox.
For the Properties, you also can set it in the Properties tab.
Congratulations!
You have finished to learn how to use VS2010 designer to bind a object(and its property) to the winForm Controller.
Then you can run this application, add records to the DataGridView, you will see that the value in the TextBox also changed when you set some value to the match property.
The following is a view when the application is running.
You can download the whole demo project from my sky driver:
PS:我的同事开发了一个MSDN论坛的小工具,有兴趣的朋友可以试试,此工具已开始在国内推行: