zoukankan      html  css  js  c++  java
  • CheckedComboBoxEditExtension

    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(", ", ",");
            }
        }
  • 相关阅读:
    Windows进程端口相关命令
    SpringMVC获取请求的匹配方法对应的路径
    Feign配置远程调用时携带原请求的token
    LINUX的patch文件 何打patch
    如何制作LINUX的patch文件及如何打patch
    (转) 跟我一起写 Makefile --- 陈皓
    u-boot移植到mini2440,增加DM9000驱动的学习笔记
    DNW PL2303驱动解决问题
    kermit的安装,配置
    wpf中bool按钮三种方式
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/9233750.html
Copyright © 2011-2022 走看看