标签:
下拉列表
属性:
行为:
DrawMode
DropDownHeight
DropDownWidth
IntegralHeight
ItemHeight
MaxDropDownItems
MaxLength
Sorted
数据:
DataSource
DisplayMember
Items
ValueMember
杂项:
AutoCompleteCustomSource
AutoCompleteMode
AutoCompleteSource
FormatString
FormattingEnabled
事件:
DropDown
DropDownClosed
DropDownStyleChanged
MeasureItem
SelectionChangeCommitted
TextUpdate
添加项:
1 private void DoBindData() 2 { 3 for (int i = 0; i < 5; i++) 4 { 5 comboBox1.Items.Add(i + 1); 6 } 7 }
添加数据源:
1 private void DoBindDataSource() 2 { 3 //构造数据源(或从数据库中查询) 4 DataTable ADt = new DataTable(); 5 DataColumn ADC1 = new DataColumn("F_ID", typeof(int)); 6 DataColumn ADC2 = new DataColumn("F_Name", typeof(string)); 7 ADt.Columns.Add(ADC1); 8 ADt.Columns.Add(ADC2); 9 for (int i = 0; i < 3; i++) 10 { 11 DataRow ADR = ADt.NewRow(); 12 ADR[0] = i+1; 13 ADR[1] = "Name_" + (i+1); 14 ADt.Rows.Add(ADR); 15 } 16 //进行绑定 17 comboBox1.DisplayMember = "F_Name";//控件显示的列名 18 comboBox1.ValueMember = "F_ID";//控件值的列名 19 comboBox1.DataSource = ADt; 20 }
标签:
原文地址:http://www.cnblogs.com/yingzhongwen/p/4413688.html