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(", ", ",");
            }
        }
  • 相关阅读:
    QT资料大全
    网络协议及tcp协议详解
    QT和Java的跨平台
    QString转char *
    QT删除整个文件夹
    QT获取linux下的当前用户名
    std::map自定义类型key
    QT程序自启动
    linux下通过命令连接wifi
    Rsync实现文件的同步
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/9233750.html
Copyright © 2011-2022 走看看