private void InitData_treeview_pingtai() { //添加根节点 TreeNode root = new TreeNode(); root.Text = "全部"; root.ImageIndex = 0; try { PingTaiRepository ptrepository = new PingTaiRepository(); IList <PingTai> list = ptrepository.GetPingTaiInfos(); foreach (PingTai pt in list) { TreeNode tempnode = new TreeNode(); tempnode.Text = pt.Dmcpt; tempnode.Tag = pt.Dmcod; tempnode.ImageIndex = int.Parse(pt.Dmcod); root.Nodes.Add(tempnode); treeview_pingtai.Nodes.Add(root); } } catch (Exception ex) { } }
private void Init_cb_pingtai() { try { PingTaiRepository ptrepository = new PingTaiRepository(); cb_pingtai.DataSource = ptrepository.GetPingTaiInfos(); cb_pingtai.DisplayMember = "dmcpt"; cb_pingtai.ValueMember = "dmcod"; } catch (Exception ex) { } }