private void btnRefresh_Click(object sender, EventArgs e) { treeView.Nodes.Clear(); cmbCateID.Items.Clear(); //Add root node TreeNode root = new TreeNode("细胞分类"); TreeNodeTag tag; tag = new TreeNodeTag(); tag.Id = 0; tag.NodeType = TreeNodeType.Root; root.Tag = tag; treeView.Nodes.Add(root); treeView.SelectedNode = root; IList <Category> lstCate; IList <Types> lstTypes; //Category lstCate = cateDao.GetList(); foreach (Category cate in lstCate) { TreeNode cateNode = new TreeNode(cate.CategoryName); tag = new TreeNodeTag(); tag.Id = cate.CateId; tag.NodeType = TreeNodeType.Category; cateNode.Tag = tag; treeView.SelectedNode.Nodes.Add(cateNode); treeView.SelectedNode = cateNode; cmbCateID.Items.Add(cate.CateId); //Type { lstTypes = typesDao.GetListByCategory(cate.CateId); foreach (Types type in lstTypes) { TreeNode typeNode = new TreeNode(type.CellType); tag = new TreeNodeTag(); tag.Id = type.TypeId; tag.NodeType = TreeNodeType.Type; typeNode.Tag = tag; treeView.SelectedNode.Nodes.Add(typeNode); } } treeView.SelectedNode = root; } treeView.ExpandAll(); }
private void cmbCate_SelectChange(object sender, EventArgs e) { try { int CateId = DataUtility.ParseInt( cmbMarkCategory.Text.Substring(0, cmbMarkCategory.Text.IndexOf('_'))); cmbMarkType.Items.Clear(); if (CateId > 0) { lstTypes = typesDao.GetListByCategory(CateId); foreach (var v in lstTypes) { cmbMarkType.Items.Add(string.Format("{0}_{1}", v.TypeId, v.CellType)); } cmbMarkType.SelectedIndex = 0; } } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } }