Example #1
0
        /// <summary>
        /// 绑定下拉列表控件为指定的数据字典列表
        /// </summary>
        /// <param name="combo">下拉列表控件</param>
        /// <param name="dictTypeName">数据字典类型名称</param>
        /// <param name="defaultValue">控件默认值</param>
        public static void BindDictItems(this CustomGridLookUpEdit combo, string dictTypeName, string defaultValue)
        {
            string       displayName = dictTypeName;
            const string valueName   = "值内容";
            const string pinyin      = "拼音码";
            DataTable    dt          = DataTableHelper.CreateTable(string.Format("{0},{1},{2}", displayName, valueName, pinyin));

            Dictionary <string, string> dict = BLLFactory <DictData> .Instance.GetDictByDictType(dictTypeName);

            foreach (string key in dict.Keys)
            {
                DataRow row = dt.NewRow();
                row[displayName] = key;
                row[valueName]   = dict[key];
                row[pinyin]      = Pinyin.GetFirstPY(key);
                dt.Rows.Add(row);
            }

            combo.Properties.ValueMember   = valueName;
            combo.Properties.DisplayMember = displayName;
            combo.Properties.DataSource    = dt;
            combo.Properties.PopulateViewColumns();
            combo.Properties.View.Columns[valueName].Visible = false;
            combo.Properties.View.Columns[displayName].Width = 400;
            combo.Properties.View.Columns[pinyin].Width      = 200;
            combo.Properties.PopupFormMinSize = new System.Drawing.Size(600, 0);

            if (!string.IsNullOrEmpty(defaultValue))
            {
                combo.EditValue = defaultValue;
            }
        }
        /// <summary>
        /// 绑定下拉列表控件为指定的数据字典列表
        /// </summary>
        /// <param name="combo">下拉列表控件</param>
        /// <param name="itemList">数据字典列表</param>
        /// <param name="defaultValue">控件默认值</param>
        public static void BindDictItems(this CustomGridLookUpEdit combo, List <CListItem> itemList, string defaultValue)
        {
            string       displayName = "显示内容";
            const string valueName   = "值内容";
            const string pinyin      = "拼音码";
            DataTable    dt          = DataTableHelper.CreateTable(string.Format("{0},{1},{2}", displayName, valueName, pinyin));

            foreach (CListItem item in itemList)
            {
                DataRow row = dt.NewRow();
                row[displayName] = item.Text;
                row[valueName]   = item.Value;
                row[pinyin]      = Pinyin.GetFirstPY(item.Text);
                dt.Rows.Add(row);
            }

            combo.Properties.ValueMember   = valueName;
            combo.Properties.DisplayMember = displayName;
            combo.Properties.DataSource    = dt;
            combo.Properties.PopulateViewColumns();
            combo.Properties.View.Columns[valueName].Visible = false;

            if (!string.IsNullOrEmpty(defaultValue))
            {
                combo.Text = defaultValue;
            }

            if (!string.IsNullOrEmpty(defaultValue))
            {
                combo.EditValue = defaultValue;
            }
        }
Example #3
0
 /// <summary>
 /// 绑定下拉列表控件为指定的数据字典列表
 /// </summary>
 /// <param name="combo">下拉列表控件</param>
 /// <param name="dictTypeName">数据字典类型名称</param>
 public static void BindDictItems(this CustomGridLookUpEdit combo, string dictTypeName)
 {
     BindDictItems(combo, dictTypeName, null);
 }
 /// <summary>
 /// 绑定下拉列表控件为指定的数据字典列表
 /// </summary>
 /// <param name="combo">下拉列表控件</param>
 /// <param name="itemList">数据字典列表</param>
 public static void BindDictItems(this CustomGridLookUpEdit combo, List <CListItem> itemList)
 {
     BindDictItems(combo, itemList, null);
 }
 /// <summary>
 /// 设置下拉列表选中指定的值
 /// </summary>
 /// <param name="combo">下拉列表</param>
 /// <param name="value">指定的CListItem中的值</param>
 public static void SetComboBoxItem(this CustomGridLookUpEdit combo, string value)
 {
     combo.EditValue = value;
 }
 /// <summary>
 /// 获取下拉列表的值
 /// </summary>
 /// <param name="combo">下拉列表</param>
 /// <returns></returns>
 public static string GetComboBoxValue(this CustomGridLookUpEdit combo)
 {
     return(combo.EditValue as string);
 }