Visual C#中的(ComboBox)数据绑定
2009-03-27 10:15
239 查看
五、复杂型组件的数据绑定:
在上面的介绍中,了解到对复杂型组件的数据绑定是通过设定组件的某些属性来完成数据绑定的。首先来介绍一下ComboBox组件的数据绑定。
(1).ComboBox组件的数据绑定:
在得到数据集后,只有设定好ComboBox组件的的三个属性就可以完成数据绑定了,这三个属性 是:"DisplayMember"、"ValueMember"。其中"DataSource"是要显示的数据集,"DisplayMember"是 ComboBox组件显示的字段,"ValueMember"是实际使用值。具体如下:
注释:此时绑定是Access 2000数据库中"person"表的"xm"字段。由此可以得到ComboBox组件数据绑定的源程序代码(Combo01.cs),本代码操作数据库是Access 2000:
得到了ComboBox组件对本地数据库的数据绑定程序,也就十分方便的得到ComboBox组件绑定Sql Server 2000源程序代码(Combox02.cs)具体如下:
在上面的介绍中,了解到对复杂型组件的数据绑定是通过设定组件的某些属性来完成数据绑定的。首先来介绍一下ComboBox组件的数据绑定。
(1).ComboBox组件的数据绑定:
在得到数据集后,只有设定好ComboBox组件的的三个属性就可以完成数据绑定了,这三个属性 是:"DisplayMember"、"ValueMember"。其中"DataSource"是要显示的数据集,"DisplayMember"是 ComboBox组件显示的字段,"ValueMember"是实际使用值。具体如下:
ComboBox1.DataSource = myDataSet ; ComboBox1.DisplayMember = "person.xm" ; ComboBox1.ValueMember = "person.xm" ; |
public class Form1 : Form |
public class Form1 : Form |
相关文章推荐
- WinForm 中 comboBox控件之数据绑定
- MVVM模式WPF的ComboBox数据绑定,使用Dictionary作为数据源
- DevExpress ASPxComboBox数据绑定问题
- Winfrom 中 ComboBox 绑定数据后设置选定项问题
- C# comboBox1绑定数据集
- DataGridView嵌入comboBox以及DataGridViewComboBoxColumn数据绑定
- Devexpress 使用comboBoxEdit 和LookUpEditor 控件数据绑定
- datatable绑定comboBox显示数据[C#]
- WinForm控件复杂数据绑定常用数据源(对Combobox,DataGridView等控件DataSource赋值的多种方法)
- Combobox 控件绑定数据
- 下拉框(ComboBox)数据绑定时触发SelectedIndexChanged事件的初步解决
- winform有一个combobox和一个textbox控件,如何进行动态绑定,使得combobox中的数据改变时,textbox中的数据也随之改变?
- Xaml中如何对ComboBox绑定一个数据集合
- DataGridView 控件中轻松设置DataGridViewComboBoxColumn数据绑定属性。
- datagridview (三)DataGridViewComboBoxColumn 列或者DataGridViewComboBoxCell 赋值绑定数据的方法
- datagridview,textbox,combobox的数据绑定,数据赋值,picturebox的用法
- WinForm控件复杂数据绑定常用数据源(如:Dictionary)(对Combobox,DataGridView等控件DataSource赋值的多种方法)
- FLEX4 DropDownList/combobox双向数据绑定binding默认赋值
- easyui datagrid动态修改editor时动态绑定combobox的数据
- C#初学踩坑日记-ListBox和ComboBox数据绑定同一个DataSet的问题