自己涉及到的控件简单使用实例(一)ComboBox
来源:互联网 发布:淘宝卖手机要什么条件 编辑:程序博客网 时间:2024/05/11 04:17
一、Combox
1 通过datatable给combox设置内容项:
private void Window_Loaded(object sender, RoutedEventArgs e) { Getvalue(); } void Getvalue() { DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("Value"); for (int i = 0; i < 10;i++ ) { DataRow dr = dt.NewRow(); dr["Name"] = i.ToString(); dr["Value"] = i.ToString(); dt.Rows.Add(dr); } this.comboBox1.DisplayMemberPath = "Value";//用来设置界面combox绑定的datatable的某列的值! this.comboBox1.ItemsSource = dt.DefaultView;//combox数据绑定方式和实现方法 } //函数重载 签名不一样(签名包含函数名和参数,不包含返回值!) void Getvalue(string value) { DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add(value); for (int i = 0; i < 10; i++) { DataRow dr = dt.NewRow(); dr["Name"] = i.ToString(); dr[value] = (i + 1).ToString(); dt.Rows.Add(dr); } this.comboBox1.DisplayMemberPath = value; this.comboBox1.ItemsSource = dt.DefaultView; } // private void button1_Click(object sender, RoutedEventArgs e) { Getvalue("Value_1"); }
Combobox.SelectedIndex=0 ;//表示默认显示第一个值 索引值0代表第一个!
效果如下:: 点击按钮后
0 0
- 自己涉及到的控件简单使用实例(一)ComboBox
- 自己涉及到的控件简单使用实例(二)DataGrid
- 自己涉及到的控件简单使用实例(三)AutoCompleteBox
- jQuery easyui combobox的使用 简单实例
- combobox控件的使用
- comboBox控件的使用
- 简单的自定义Combobox控件
- 自己所实现的在datagrid控件里面使用combobox控件的过程
- easyui-combobox的简单使用
- android简单实例---------ActionBar的简单使用(一)
- 一个使用Fragement控件的简单实例
- MFC控件ComboBox(一)
- 涉及到的函数(自己查看使用,文章格式很乱)
- listview控件使用实例(一)
- VC中ComboBox控件的使用
- vc6.0 Combobox控件的使用问题
- VC中ComboBox控件的使用
- VC++ 之 ComboBox控件的使用
- 在代码中更改TextView中字体的颜色
- Linux Bash Shell快速入门
- Oracle基础知识:在PL/SQL中修改ORACLE的字段顺序
- 网络字节顺序
- Lustre I/O性能特点与最佳实践
- 自己涉及到的控件简单使用实例(一)ComboBox
- 获取上G的文件行数的最快速的代码
- JAVA数组的equals方法
- 安装PHP与Apache、mysql匹配
- Android Studio升级后工程Build failed.
- 第六节swift 一元操作符
- Python:2D绘图库matplotlib学习总结
- Driver.obj : error LNK2019: unresolved external symbol __except_handler4 referenced in function "lon
- Vertica 常用命令