一、属性介绍
1. (Name)
控件的对象标识符ID
2. Items
组合框中的集合项
3. BackColor
控件的背景颜色
4. Cursor
鼠标移过该控件显示的光标样式
5. DropDownStyle
组合框的下拉样式和功能
6. FlatStyle
控件的外观
7. Font
控件的字体样式
8. ForeColor
控件的文本颜色
9. Text
控件的文本
10. UseWaitCursor
使用鼠标的等待光标
11. Enabled
控件激活状态
12. Visible
控件显示状态
二、事件介绍
1. SelectedIndexChanged
组合框中选择的项发生改变时触发。
三、方法介绍
1. // Text 获取的为控件显示的内容
string str = comboBox1.Text;
2. // SelectedItem 获取的为当前选择的对象(当对选择的对象修改时,会获取null异常)
string str2 = comboBox1.SelectedItem.ToString();
3. string str3 = comboBox1.SelectedText; // 值为:""
4. Object obj = comboBox1.SelectedValue; // 值为:null(null无法ToString)
5. // SelectedIndex 获取的为当前选择的索引
int index = comboBox1.SelectedIndex;
6. //向集合追加单个成员
comboBox1.Items.Add("C#");
7. //向集合追加数组成员
comboBox1.Items.AddRange(new string[] { "设置", "参数", "OK" });