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. IE8中伪元素动态作用样式不重绘bug记录

    前阵子对公司框架的前端优化中,使用了字体图标(iconfont)来做模块的图标集,供用户进行配置选择. 字体图标的有非常好的灵活性和复用性,可以像处理文字一样通过font-size进行大小设置.通过c ...

  2. idea启动崩溃问题

    idea启动崩溃问题 内存已经给到1024m了: 注意到项目比较大,有个参数ReservedCodeCasheSize,把这个修改为1024m, 学习了:https://www.cnblogs.com ...

  3. Inf2Cat应用的参数使用详细介绍

    http://msdn.microsoft.com/zh-cn/subscriptions/ff547089   Inf2Cat Inf2Cat (Inf2Cat.exe) 是一个命令行工具,该工具确 ...

  4. C++类型转换的经典例子

  5. VM虚拟机Failed to initialize remote display subsystem怎么办

    1 如图所示,启动虚拟机的时候出现提示Failed to initialize remote display subsystem.怎么办 2 进入DOS窗口,输入net user __vmware_u ...

  6. 高德地图引入库错误std::string::find_first_of(char const*, unsigned long, unsigned long) const"

    一:std:编译器错误解决 二:错误提示 "std::string::find_first_of(char const*, unsigned long, unsigned long) con ...

  7. 给你一个能生成1到5随机数的函数,用它写一个函数生成1到7的随机数。 (即,使用函数rand5()来实现函数rand7())

    给你一个能生成1到5随机数的函数,用它写一个函数生成1到7的随机数. (即,使用函数rand5()来实现函数rand7()). 解答 rand5可以随机生成1,2,3,4,5:rand7可以随机生成1 ...

  8. web应用程序访问串口

    https://github.com/tylermenezes/SerialServe https://github.com/straend/SerialWebsocket http://www.cn ...

  9. maven的下载以及安装

    1.下载Maven 打开链接:https://maven.apache.org/download.cgi 下载好之后解压到一个盘,我的是解压到F:\Maven\apache-maven-3.5.3-b ...

  10. Swift教程_swift常见问题(0005)_完美解决Cannot override &#39;dealloc&#39;异常

    Swift教程_swift常见问题(0001)_CoreData: warning: Unable to load class named 'xxx' for entity 'xxx' Swift教程 ...