Esempio n. 1
0
        /// <summary>
        /// Setup a dropdown control from a dictionary
        /// </summary>
        /// <param name="ctl">Control to set up</param>
        /// <param name="dictName">dictionary name, null to reset control</param>
        /// <param name="reload">reload the list even if previously loaded</param>
        /// <returns></returns>

        public static bool SetListControlItemsFromDictionary(
            object ctlObj,
            string dictName,
            bool reload)
        {
            List <string> dict;
            int           begRow, rowSel, i1;

            if (dictName == null || dictName == "")
            {             // no dictionary, clear dropdown
                UIMisc.SetListControlItems(ctlObj, "");
                return(true);
            }

            dict = DictionaryMx.GetWords(dictName, true);
            if (dict == null)
            {
                return(false);
            }

            StringBuilder buf = new StringBuilder();

            foreach (string s in dict)
            {
                if (buf.Length > 0)
                {
                    buf.Append("\n");
                }
                buf.Append(s);
            }

            UIMisc.SetListControlItems(ctlObj, buf.ToString());

            return(true);
        }