private void AddAllCatNodes(DataTable table) { int i = 0; if (CatHashes == null) return; foreach (Hashtable ht in CatHashes) { ArrayList al_NodesInLevel = FindAllTreeNodesByLevel(i - 1); foreach (TreeNode node in al_NodesInLevel) { if (node.Tag != null) { try { if(!(node.Tag is string)) { object[] tags = (object[])node.Tag; if (tags[0].ToString() == "-1") continue; } } catch {} } int newnodelevel = 0; TreeNodeCollection tnc; if (node.Name == "root") { tnc = this.baseTree.Nodes; newnodelevel = 0; } else { tnc = node.Nodes; newnodelevel = node.Level + 1; } ArrayList al_ht = new ArrayList(ht); StringComparer comboComp = new StringComparer(); al_ht.Sort(comboComp); foreach (DictionaryEntry de in al_ht) { bool fAlreadyExists = false; TreeNode nFound = null; foreach (TreeNode n in tnc) { if (n.Tag.ToString() == de.Key.ToString()) { fAlreadyExists = true; nFound = n; break; } } if (!fAlreadyExists) { object[] ret = ((PageDesc)m_Pages[0]).dbClass.CallLuaFunction("CustomCategory", new object[] { newnodelevel, de.Key.ToString(), de.Value.ToString(), table }); TreeNode newnode = (ret == null) ? tnc.Add(de.Value.ToString()) : tnc.Add(ret[0].ToString()); newnode.Tag = de.Key.ToString(); } else { if (nFound.Text != de.Value.ToString()) nFound.Text = de.Value.ToString(); } } } i++; } }
//转为下拉框 public TypeConverter.StandardValuesCollection GetValues() { if (m_CollectionValue == null) { int ncount = 0; if (ComboValues == null || ComboValues.Count <= 0) return null; string[] comvalue = new string[ComboValues.Count]; ArrayList a_combovalues = new ArrayList(ComboValues); StringComparer comboComp = new StringComparer(); a_combovalues.Sort(comboComp); foreach (DictionaryEntry kv in /*ComboValues*/a_combovalues) { comvalue[ncount++] = (string)kv.Key; } m_CollectionValue = new TypeConverter.StandardValuesCollection(comvalue); } return m_CollectionValue; }
/// <summary> /// 改变catHashes里的value为要显示的值---此函数改变了CatHashes /// </summary> /// <param name="nDepth"></param> /// <param name="strKey"></param> /// <param name="table"></param> /// <returns></returns> private void InitCatDisplayText(DataTable table) { if (CatHashes == null) { return; } int nDepth = -1; foreach (Hashtable ht in CatHashes) { nDepth++; ArrayList al_ht = new ArrayList(ht); StringComparer comboComp = new StringComparer(); al_ht.Sort(comboComp); foreach (DictionaryEntry de in al_ht) { object[] ret = ((PageDesc)m_Pages[0]).dbClass.CallLuaFunction("CustomCategory", new object[] { nDepth, de.Key.ToString(), de.Value.ToString(), table }); if (ret != null) { ht[de.Key] = ret[0].ToString(); } } } }