/// <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); }
/// <summary> /// Setup a dropdown control from a dictionary /// </summary> /// <param name="items">Control item collection to fill</param> /// <param name="dictName">Dictionary name, null to reset control</param> public static void SetListControlItemsFromDictionary( ComboBoxItemCollection items, string dictName, bool removeDuplicates) { items.Clear(); if (String.IsNullOrEmpty(dictName)) { return; } List <string> words = DictionaryMx.GetWords(dictName, removeDuplicates); if (words == null) { return; } items.AddRange(words); return; }
internal void SetupCheckedListBoxFromDictionary( string dictName, string criteria) { List <string> vList = new List <string>(); List <string> excludeList = new List <string>(); List <string> dictWords; bool itemChecked; SearchText.Text = ""; dictWords = DictionaryMx.GetWords(dictName, false); if (dictWords == null) { throw new Exception("Dictionary not found: " + dictName); } Insetup = true; ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(criteria); if (psc != null) { if (psc.ValueList != null) { vList = psc.ValueList; } else if (!Lex.IsNullOrEmpty(psc.Value)) { vList.Add(psc.Value); } } HashSet <string> hashSet = new HashSet <string>(vList); CheckList.Items.Clear(); int si = -1; foreach (string key in dictWords) { if (Lex.Eq(dictName, "STRUCTURE_DATABASES") && Lex.Eq(key, "UserDatabase")) { continue; // special-case fix - generalize later } CheckedListBoxItem clbi = new CheckedListBoxItem(); clbi.Description = key; if (hashSet.Contains(key)) { clbi.CheckState = CheckState.Checked; if (si < 0) { si = CheckList.Items.Count; } } else { clbi.CheckState = CheckState.Unchecked; } CheckList.Items.Add(clbi); } if (si >= 0) { CheckList.SelectedIndex = si; CheckedListBoxItem clbi = CheckList.Items[si]; SearchText.Text = clbi.Description; } SelectedItemText.Text = SelectedItemText.ToolTip = GetCheckedListItems(); Insetup = false; return; }