DevExpress下拉多选框 CheckComboboxEdit、CheckedListBoxControl
CheckComboboxEdit
//清空项
checkedComboBoxEdit1.Properties.Items.Clear();
//自定义数组
string[] strs=new string[]{"新建","审批中","已完成","已撤销"};
//添加项
checkedComboBoxEdit1.Properties.Items.AddRange(strs);
//设置选中状态
if(checkedComboBoxEdit1.Properties.Items.Count>0){
//设置选中状态
checkedComboBoxEdit1.Properties.Items[strs[0]].CheckState = CheckState.Checked;
//设置选项是否可用
checkedComboBoxEdit1.Properties.Items[strs[0]].Enabled = false;
}
//取值
checkedComboBoxEdit1.EditValue.ToString();
//获取各项值 放在List集合中
List<object> List = checkedComboBoxEdit1.Properties.Items.GetCheckedValues();
//注意 当取得值是多项时,各项之间的间隔是 英文状态下 逗号+空格
//转换方法
string result = checkedComboBoxEdit1.EditValue.ToString().Replace(", ", ",");
//是否显示 确定、取消按钮
checkedComboBoxEdit1.Properties.ShowButtons = false;
//是否显示 取消按钮
checkedComboBoxEdit1.Properties.ShowPopupCloseButton = false;
//下拉显示项的个数 (设置为下拉个数加1正好可以显示全部,因为有一行是全选项)
checkedComboBoxEdit1.Properties.DropDownRows = checkedComboBoxEdit1.Properties.Items.Count + 1;
CheckedListBoxControl
//自定义一个表
DataTable dt = new DataTable();
dt.Columns.Add("ID");
dt.Columns.Add("Name");
dt.Columns.Add("Sex");
for (int i = 0; i < 30; i++) {
DataRow dr = dt.NewRow();
dr["ID"] = i + 1;
dr["Name"]=Convert.ToString((char)(65+i))+Convert.ToString((char)(65+i));
dr["Sex"] = i % 2==0?"男":"女";
dt.Rows.Add(dr);
}
//清空项
checkedListBoxControl1.Items.Clear();
//绑定
checkedListBoxControl1.DataSource = dt;
checkedListBoxControl1.ValueMember = "ID";
checkedListBoxControl1.DisplayMember = "Name";
//全选
//checkedListBoxControl1.CheckAll();
//项的个数
int itemCount = checkedListBoxControl1.ItemCount;
//添加项(如果设置绑定,添加项无效)
checkedListBoxControl1.Items.Add("kk");
//设置选中状态、显示值、实际值、是否可用(如果设置绑定,这些将会无效)
checkedListBoxControl1.Items[0].CheckState = CheckState.Checked;
checkedListBoxControl1.Items[0].Description = "显示值";
checkedListBoxControl1.Items[0].Value = "实际值";
checkedListBoxControl1.Items[0].Enabled = false;
//效果和上面一样
checkedListBoxControl1.SetItemChecked(0, true);
checkedListBoxControl1.SetItemCheckState(0, CheckState.Checked);
checkedListBoxControl1.SetItemValue("实际值",0);
//是否被勾选
bool isChecked= checkedListBoxControl1.GetItemChecked(0);
//获取某项状态
string checkState = checkedListBoxControl1.GetItemCheckState(0).ToString();
//获取某项绑定值 valueMember
string trueValue = checkedListBoxControl1.GetItemValue(0).ToString();
//获取某项显示值 displayMember
string disValue = checkedListBoxControl1.GetDisplayItemValue(0).ToString();
string disValue2 = checkedListBoxControl1.GetItemText(0);
//是否点击一次 就改变状态
checkedListBoxControl1.CheckOnClick = true;
//是否多列显示
checkedListBoxControl1.MultiColumn = true;
//checkedListboxControl 是否获得焦点
bool isfocus=checkedListBoxControl1.ContainsFocus;
//实现单选功能
checkedListBoxControl1.SelectedIndexChanged += new EventHandler(checkedListBoxControl1_SelectedIndexChanged);
//获取选中项的绑定值(前提:手动添加的可以获取,但是datatable绑定的无法获取)
List<object> objList = checkedListBoxControl1.Items.GetCheckedValues();
void checkedListBoxControl1_SelectedIndexChanged(object sender, EventArgs e)
{
int index=checkedListBoxControl1.SelectedIndex;
for (int i = 0; i < checkedListBoxControl1.ItemCount; i++) {
if (i != index)
{
checkedListBoxControl1.SetItemChecked(i, false);
}
}
}
#region public static void SetComboBoxData(DevExpress.XtraEditors.ImageComboBoxEdit comboBox,List<T> list, string valueMember, string displayMember, string selectedText = null)
/// <summary>
/// 绑定下拉框
/// </summary>
/// <param name="comboBox">下拉控件</param>
/// <param name="List<T> ">实体集合</param>
/// <param name="valueMember">值字段</param>
/// <param name="displayMember">显示字段</param>
/// <param name="selectedText">默认选中的值</param>
public static void SetComboBoxData<T>(DevExpress.XtraEditors.ImageComboBoxEdit comboBox, List<T> list, string valueMember, string displayMember, string selectedText = null)//
{
comboBox.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
comboBox.Properties.NullText = string.Empty; foreach (var item in list)
{
comboBox.Properties.Items.Add(new ImageComboBoxItem(item.GetType().GetProperty(valueMember).GetValue(item, null).ToString(), item.GetType().GetProperty(valueMember).GetValue(item, null).ToString()));
} // //这里是设置默认选中的值
if (!string.IsNullOrEmpty(selectedText))
{
comboBox.SelectedItem = comboBox.Properties.Items.GetItem(selectedText);
}
}
#endregion
http://www.cnblogs.com/spring_wang/archive/2013/05/11/3072640.html
https://blog.csdn.net/xiaoyu812289718/article/details/43017755
https://blog.csdn.net/u013816709/article/details/48159309
DevExpress下拉多选框 CheckComboboxEdit、CheckedListBoxControl的更多相关文章
- 我的第一个jquery插件:下拉多选框
<!DOCTYPE HTML> <html> <head> <title> New Document </title> <meta n ...
- 使用jQuery为文本框、单选框、多选框、下拉框、下拉多选框设值及返回值的处理
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- angular2.x 下拉多选框选择组件
angular2.x - 5.x 的下拉多选框选择组件 ng2 -- ng5.最近在学angular4,经常在交流群看见很多人问 下拉多选怎么做... 今天就随便写的个. 组件源码 百度云 链接: ...
- 品优购商城项目(二)AngularJS、自动代码生成器、select2下拉多选框
品优购商城想项目第二阶段 AngularJS.自动代码生成器.select2下拉多选框 完成了课程第三天.第四天的的任务. 1.学习了AngularJs前端的mvc分层思想,js部分分成control ...
- 自己用ul模拟实现下拉多选框,
模拟实现下拉多选框 效果如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- jquery--获取多选框的值、获取下拉多选框的值
获取多选框的值 var packageCodeList=new Array(); $('#server_id:checked').each(function(){ packageCodeList.pu ...
- 自定义实现 PyQt5 下拉复选框 ComboCheckBox
一.前言 由于最近的项目需要具有复选功能,但过多的复选框会影响界面布局和美观,因而想到把 PyQt5 的下拉列表和复选框结合起来,但在 PyQt5 中并没有这样的组件供我们使用,所以想要自己实现一个下 ...
- selectpicker下拉多选框ajax异步或者提前赋值=》默认值
Bootstrap select多选下拉框赋值 success: function (data) { var oldnumber = new Array(); $.each(data, functio ...
- 设置Select下拉多选框功能,赋值与绑定问题
项目需要所以更改select为多选下拉的菜单选项. 我用的是后台直接绑定 在前台aspx页面直接写一个 <div id="dropsxs" runat="serve ...
随机推荐
- PHP PSR基本代码规范(中文版)
PSR-1 基本代码规范 本篇规范制定了代码基本元素的相关标准,以确保共享的PHP代码间具有较高程度的技术互通性. 关键词 “必须”("MUST").“一定不可/一定不能”(&qu ...
- Inside GDALAllRegister之一: 五大部分
基本信息 在GDAL的Tutorial中开篇即提到GDALAllRegister函数,它会注册所有已知的驱动,包括动态库自动加载的驱动.最关键是这句话: If for some application ...
- python 初步学习
疑惑1:windows下的python 如何设置显示汉字 推荐几个学习网址,也方便自己以后查看: http://pmghong.blog.51cto.com/3221425/d-10 www.w3c ...
- SQL Server 附加数据库提示5120错误
怎么样是不是跟你的错误是一样的,心里是不是有点小激动? T_T 终于有办法了!!!! 第一步先关掉你的SQLserver 然后在菜单上找找到SQLSERVER右键选择“以管理员运行” 第二步给你的数据 ...
- 【Nodejs】“快算24”扑克牌游戏算法 1.02
快算24是一种挺好的锻炼孩子算数能力的扑克牌游戏,它的游戏方式是把四张牌的牌面数值通过有限四则运算得到结果24,四张牌必须仅用一次.各地玩法还有点差别,有的只算1-10,其它抽出来:有的地方把整幅牌都 ...
- 实现基于DNS的负载均衡
转自:http://blog.sina.com.cn/s/blog_4e424e2101000c3g.html 如果你有一个很受欢迎的Web站点,你会发现当请求的连接数增加时,服务器的响应延时也会随之 ...
- 使用Editplus配置PHP调试环境
工欲善其事必先利其器.近期看了非常多PHP的IDE介绍.最后选择了Editplus.以下说说一些PHP的调试环境配置问题. 1. 加入PHP模板 第一步 新建->其他->php 第二步 输 ...
- BIO、NIO、AIO差别
网上非常多IO资料,对新手来说.越看越晕.依据自己的理解.总结对照了一下BIO.NIO.AIO. BIO:线程发起IO请求,无论内核是否准备好IO操作,从发起请求起,线程一直堵塞,直到操作完毕. 例如 ...
- SDK Build Tools revision (19.0.3) is too low for project Minimum required is 19.1.0
假设你正在使用Android Studio工具进行开发,且将版本号更新到0.6.0的时候.莫名的出现这种错误 SDK Build Tools revision (19.0.3) is too low ...
- 从gentoo回归Arch,上组图
Arch一直在我笔记本里边,只是玩gentoo时我不进Arch了,现在回归Arch,升级到了最新,用上了gentoo的最新的2.6.31内核(自己配置,无initrd),引导程序用的grub4dos: ...