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. 如何将DB2的数据库转换到mySQL中?

    经过几次尝试最终找到解决的办法,因为网上并没有详细说明,所以下面我将详细的步骤记录如下: 1. 大前提是你已经安装好DB2服务器和mySQL服务器,现在只是借用Navicat for MySQL这个软 ...

  2. 1-2Html与CSS的关系

    Html和CSS的关系 基于微信的后台开发须要掌握的基础知识包括有:HTML.CSS.JavaScript语言. 以下我们就来了解下这三门技术都是用来实现什么的: 1. HTML是网页内容的载体.内容 ...

  3. jQuery cssHook的经典例子

      /*--------------------------- example ------------------------------*/ $.cssHooks.foo = { get: fun ...

  4. 在Win7上安装MySql5.2遇到Write configuration file的解决

    机器从XP翻新到Win7后,原有的环境也被清除了,因此找了个时间重新安装MySql. 以前轻车熟路的过程,在最后一环却卡住了,出现Write configuration file 错误. 以前从来没有 ...

  5. 劣质代码评析——《写给大家看的C语言书(第2版)》附录B之21点程序(八)

    [重构](续) 牌的表示: 一副牌有52张,可用一整数数组描述.但是由于在游戏过程中牌数在不断减少,所以用一表示剩余张数的整数和一整数数组共同描述.C99支持一种变量长度数组,但用在这里并没有什么特别 ...

  6. python手记(42)

    #!/usr/bin/env python #-*- coding: utf-8 -*- #code:myhaspl@qq.com import cv2 import numpy as np fn1= ...

  7. ES6 async await 面试题

    转自:https://juejin.im/post/5c0397186fb9a049b5068e54 1.题目一 async function async1(){ console.log('async ...

  8. FIS3 构建 工程化

    1.安装 npm install -g fis3 //插件 npm install -g fis3-hook-relative npm install -g fis3-preprocessor-aut ...

  9. 高阶函数 实现sum(2)(3) 柯里化

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  10. line-height测量及使用

    1.line-height定义 line-height表示行高,即两行文字基线间的距离. 以下是图示说明: 行高是2条红线之间的距离,即:1+2+3+4 在实际测量中,基线不好找,可测量顶线到顶线的距 ...