Esempio n. 1
0
        /// <summary>设置组合框列表内容</summary>
        /// <param name="cb">组合框</param>
        /// <param name="lists">列表字符串</param>
        /// <param name="valnum">值索引</param>
        /// <param name="txtnum">文本索引</param>
        /// <param name="mode">组合框列模式:0 值加文本模式 1值模式</param>
        /// <param name="selval">选中值</param>
        public static void SetComboBoxItems(ComboBox cb, string lists, int valnum, int txtnum, int mode, string selval)
        {
            List <string> notVals = new List <string>();
            DataTable     rdt     = WebOften.StrToDataTable(lists);

            SetComboBoxItems(cb, "", rdt, valnum, txtnum, mode, selval, "", notVals);
        }
Esempio n. 2
0
        /// <summary>设置组合框列表内容</summary>
        /// <param name="cb">组合框</param>
        /// <param name="lists">列表字符串</param>
        /// <param name="selval">选中值</param>
        public static void SetComboBoxItems(ComboBox cb, string lists, string selval)
        {
            List <string> notVals = new List <string>();
            DataTable     rdt     = WebOften.StrToDataTable(lists);

            SetComboBoxItems(cb, "", rdt, 0, 1, 0, selval, "", notVals);
        }
Esempio n. 3
0
        /// <summary>将指定列表字符串插入到指定内存列表并返回内存列表</summary>
        /// <param name="rdt">内存列表</param>
        /// <param name="str">指定列表字符串</param>
        /// <returns>将指定列表字符串插入到指定内存列表并返回内存列表</returns>
        public static DataTable AddTable(DataTable rdt, string str)
        {
            DataTable sdt = WebOften.StrToDataTable(str, "||", "|");

            for (int i = 0; i < sdt.Rows.Count; i++)
            {
                DataRow dr = rdt.NewRow();
                dr[0] = sdt.Rows[i][0];
                dr[1] = sdt.Rows[i][1];
                rdt.Rows.Add(dr);
            }
            return(rdt);
        }
Esempio n. 4
0
        /// <summary>设置组合框列表内容</summary>
        /// <param name="cb">组合框</param>
        /// <param name="addlists">新增的列表</param>
        /// <param name="rdt">列表</param>
        /// <param name="valnum">值索引</param>
        /// <param name="txtnum">文本索引</param>
        /// <param name="mode">组合框列模式:0 值加文本模式 1值模式</param>
        /// <param name="selval">选中值</param>
        /// <param name="defselval">默认选中的值</param>
        /// <param name="notVals">不出现在列表值的集合</param>
        public static void SetComboBoxItems(ComboBox cb, string addlists, DataTable rdt, int valnum, int txtnum, int mode, string selval, string defselval, List <string> notVals)
        {
            DataTable adt = WebOften.StrToDataTable(addlists);

            cb.Items.Clear();
            int index = 0;

            for (int i = 0; i < adt.Rows.Count; i++)
            {
                DataRow dr = rdt.NewRow();
                dr[valnum] = adt.Rows[i][0].ToString().Trim();
                dr[txtnum] = adt.Rows[i][1].ToString().Trim();
                rdt.Rows.InsertAt(dr, 0);
            }
            for (int i = 0; i < rdt.Rows.Count; i++)
            {
                string val = rdt.Rows[i][valnum].ToString().Trim();
                string txt = rdt.Rows[i][txtnum].ToString().Trim();
                if (mode == 0)
                {
                    if (notVals.Count == 0 || notVals.IndexOf(val) > -1)
                    {
                        cb.Items.Add(new ValTxt(val, txt));
                        if ((selval == val) || (defselval == val))
                        {
                            cb.SelectedIndex = index;
                        }
                        index++;
                    }
                }
                else
                {
                    if (notVals.Count == 0 || notVals.IndexOf(val) > -1)
                    {
                        cb.Items.Add(val);
                        if ((selval == val) || (defselval == val))
                        {
                            cb.SelectedIndex = index;
                        }
                        index++;
                    }
                }
            }
        }