Пример #1
0
        /// <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;
            }
        }
Пример #2
0
 /// <summary>
 /// 设置下拉列表选中指定的值
 /// </summary>
 /// <param name="combo">下拉列表</param>
 /// <param name="value">指定的CListItem中的值</param>
 public static void SetComboBoxItem(this CustomGridLookUpEdit combo, string value)
 {
     combo.EditValue = value;
 }
Пример #3
0
 /// <summary>
 /// 绑定下拉列表控件为指定的数据字典列表
 /// </summary>
 /// <param name="combo">下拉列表控件</param>
 /// <param name="itemList">数据字典列表</param>
 public static void BindDictItems(this CustomGridLookUpEdit combo, List <CListItem> itemList)
 {
     BindDictItems(combo, itemList, null);
 }
Пример #4
0
 /// <summary>
 /// 获取下拉列表的值
 /// </summary>
 /// <param name="combo">下拉列表</param>
 /// <returns></returns>
 public static string GetComboBoxValue(this CustomGridLookUpEdit combo)
 {
     return(combo.EditValue as string);
 }