- 1、本文档共17页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
手工绑定combobox的方法(国外英文资料)
手工绑定combobox的方法(国外英文资料)
Data binding in Visual Studio c #
Five. Data binding for complex components:
In the introduction above, you learned that data binding to complex components is done by setting certain properties of the component to complete the data binding. Lets start with the data binding of the ComboBox component.
(1).combobox component data binding:
Once you have the data set, you can complete the data binding by setting the three properties of the ComboBox component: DisplayMember and ValueMember. The DataSource is the data set to display, DisplayMember is the field that the ComboBox component displays, and ValueMember is the actual use value. Specific as follows:
Combobox1.datasource = myDataSet;
Combobox1.displaymember = person.xm;
Combobox1.valuemember = person.xm;
Note: the binding is the xm field in the person table in the Access 2000 database. This gives you the source code (combo01.cs) of the ComboBox component data binding, which is the Access 2000:
Public class Form1: Form
{
Private ComboBox ComboBox1;
Private Button for;
Private system.data.
Private System.Com ponentModel. Container components = null;
Public _click ()
{
file:// open the data link and get the data set
GetConnect ();
InitializeComponent ();
}
The resources used in the file:// cleanup program
Protected override void Dispose (bool disposing)
{
If (disposing)
{
If (components! = null)
{
Dispose of the components.
}
}
()
}
Private void GetConnect ()
{
file:// create an OleDbConnection
String strCon = Provider = Microsoft.
OleDbConnection myConn = new OleDbConnection (strCon);
String = SELECT * FROM person;
file:// create a DataSet
MyDataSet = new DataSet ();
()
file:// use OleDbDataAdapter to get a data set
OleDbDataAdapter myCommand = new OleDbDataAdapter (strCom, myConn);
file:// bind the Dataset to the person data table
(myDataSet, person);
file:// close this OleDbConnection
MyConn. Close ();
}
Private void button1_Click (System. EventArgs e)
{
Combobox1.datasource = myDataSet;
Co
文档评论(0)