public static class CheckedComboBoxEditExtension
{
public static void BindData(this CheckedComboBoxEdit control, IList<NameValue<string>> collection, bool isShowButtons = true)
{
if (collection == null)
return;
control.Properties.Items.Clear();
control.Properties.ShowButtons = isShowButtons;
control.Properties.NullText = null;
control.Cursor = System.Windows.Forms.Cursors.Hand;
foreach (var item in collection)
{
control.Properties.Items.Add(new CheckedListBoxItem(item.Value, item.Name, CheckState.Unchecked));
}
control.CustomDisplayText += (sender, e) =>
{
var selectedCount = control.Properties.GetCheckedItems().ToString().Replace(", ", ",").Split(',').ToList().Count;
if (selectedCount == collection.Count)
{
e.DisplayText = "全部";
}
}; } public static void BindData(this CheckedComboBoxEdit control, IList<NameValue> collection, bool isShowButtons = true)
{
if (collection == null)
return;
control.Properties.Items.Clear();
control.Properties.Items.Clear();
control.Properties.ShowButtons = isShowButtons;
control.Properties.NullText = null;
control.Cursor = System.Windows.Forms.Cursors.Hand;
foreach (var item in collection)
{
control.Properties.Items.Add(new CheckedListBoxItem(item.Value, item.Name, CheckState.Unchecked));
}
control.CustomDisplayText += (sender, e) =>
{
var selectedCount = control.Properties.GetCheckedItems().ToString().Replace(", ", ",").Split(',').ToList().Count;
if (selectedCount == collection.Count)
{
e.DisplayText = "全部";
}
}; }
public static void Clear(this CheckedComboBoxEdit control)
{
control.Properties.Items.Clear();
} public static bool IsSelected(this CheckedComboBoxEdit control)
{
if (control.EditValue == null || control.EditValue.ToString().Equals(string.Empty))
{
return false;
}
return !control.EditValue.Equals("-999");
} public static bool IsNotSelected(this CheckedComboBoxEdit control)
{
return !control.IsSelected();
} /// <summary>
/// 获取多选下拉框值List
/// </summary>
/// <param name="control"></param>
/// <returns></returns>
public static IList<string> GetCheckedValueLists(this CheckedComboBoxEdit control)
{
return control.Properties.GetCheckedItems().ToString().Replace(", ", ",").Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
/// <summary>
/// 获取多选下拉框值,多个值用","连接 ;注意 当取得值是多项时,各项之间的间隔是 英文状态下 逗号+空格
/// </summary>
/// <param name="control"></param>
/// <returns></returns>
public static string GetCheckedValuestrs(this CheckedComboBoxEdit control)
{
return control.Properties.GetCheckedItems().ToString().Replace(", ", ",");
}
}

CheckedComboBoxEditExtension的更多相关文章

随机推荐

  1. CentOS7.0 x86_64系统上构建php开发环境--Lamp(包含设置虚拟文件夹,加入SELinux对httpd的支持等知识)

    一.安装mysql,直接用yum安装就可以,mysql在centos7.0版本号中被mariadb替代了. 命令: yum install mysql-server mysql 安装好了,选择改动my ...

  2. 协定须要双工,可是绑定“WSHttpBinding”不支持它或者因配置不对而无法支持它

    协定须要双工,可是绑定"WSHttpBinding"不支持它或者因配置不对而无法支持它 下面两种情况,我都遇到过. 一, < endpoint address =" ...

  3. 彻底解决 intellij IDEA 卡顿 优化笔记

    由于工作中经常出现分支各种切换,使用Eclipse便不再像以前那么舒服了,不停的修改工作空间,每次修改完工作空间又是一堆一堆的个性化设置,来回的切换,真的很累.我们做软件的,怎么能不去尝试新鲜的呢,毕 ...

  4. 用Bluepages来验证intranetId和Password的有效性

    代码很简单,如下: int ret = -1;ReturnCode rc = null;            cwa2 cw = new cwa2();rc = cw.authenticate(in ...

  5. SqlServer日常积累(二)

    1.Like运算符:将字符串表达式与 SQL表达式中的模式进行比较匹配. 语法 :expression Like 'pattern' ,expression为匹配字段,pattern为匹配字符串.可以 ...

  6. 灰度图像二值化-----c++实现

    前天闲着没事干,就写了写BMP图像处理,感觉大家还比较感兴趣..所以现在没事,继续更新..这次简单的写了灰度图像二值化..这是什么概念呢? 图像的二值化的基本原理 图像的二值化处理就是将图像上的点的灰 ...

  7. IOS企业开发者帐号申请

    想使用 XCode 的联机调试功能,必须先注册成为苹果开发者,再出99刀加入苹果 iOS 开发者计划才可以.加入苹果 iOS 开发者计划的方法 Google 一下就会找到很多链接.但是这些链接的内容都 ...

  8. windows下npm默认的全局路径

    C:\Users\用户名\AppData\Roaming\npm\node_modules

  9. Java多线程(1) 创建

    一.线程的生命周期及五种基本状态 关于Java中线程的生命周期,首先看一下以下这张较为经典的图: Java线程具有五中基本状态 新建状态(New):当线程对象对创建后,即进入了新建状态,如:Threa ...

  10. SQL Sever 2008配置工具中过程调用失败解决方法

    刚刚装了VS2013.然后打开数据库时,不管怎样也连不上.打开数据库配置,出现例如以下界面: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbHU5MzAx ...