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(", ", ",");
            }
        }
  • 相关阅读:
    解析Javascript事件冒泡机制
    LeetCode——Flatten Binary Tree to Linked List
    流动python
    HDU2586
    Cannot find ActionMappings or ActionFormBeans collection
    reactor设计模式
    简单的Ajax应用实例
    CString——Left、Right、Find、ReverseFind
    MATLAB新手教程
    八大排序算法总结
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/9233750.html
Copyright © 2011-2022 走看看