博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Binding object to winForm controller through VS2010 Designer(通过VS2010设计器将对象绑定到winForm控件上)...
阅读量:4947 次
发布时间:2019-06-11

本文共 1694 字,大约阅读时间需要 5 分钟。

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论坛的小工具,有兴趣的朋友可以试试,此工具已开始在国内推行:

转载于:https://www.cnblogs.com/telnet_mike/archive/2011/03/16/1986360.html

你可能感兴趣的文章
小程序和web画三角形
查看>>
vue兄弟组件之间的通信(bus.js)方法
查看>>
vue状态管理(vuex)
查看>>
css画圆弧
查看>>
解决mysql安装到最后一步弹出窗口无响应的方法
查看>>
C/C++误区
查看>>
POJ 3585 Accumulation Degree (算竞赛进阶习题)
查看>>
2019牛客暑期多校训练营(第一场)- B Integration
查看>>
2019牛客暑期多校训练营(第一场)- E ABBA
查看>>
2019牛客暑期多校训练营(第二场)- Kth Minimum Clique
查看>>
2019牛客暑期多校训练营(第二场)- H Second Large Rectangle
查看>>
HDU3949 XOR
查看>>
2019牛客暑期多校训练营(第四场)- sequence
查看>>
2019 Multi-University Training Contest 2 - Longest Subarray
查看>>
2019 Multi-University Training Contest 3 - D Distribution of books
查看>>
2019 Multi-University Training Contest 4 - Minimal Power of Prime
查看>>
2019 Multi-University Training Contest 4 - K-th Closest Distance
查看>>
2019牛客暑期多校训练营(第六场)- Shorten IPv6 Address
查看>>
2019牛客暑期多校训练营(第五场)- generator 1
查看>>
2019 Multi-University Training Contest 6 - Snowy Smile
查看>>