//鼠标单击树节点发生 private void tvndtlist_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { con_ndt myObj = (con_ndt)e.Node.Tag; lvndtdes.Items.Clear(); con_ndt myPerson = new con_ndt(); OleDbDataReader myReader = myPerson.GetAllCONNDTDR(myObj.ndt_id); //得到ndt_id _ndt_id = (int)myObj.ndt_id; while (myReader.Read()) { ListViewItem myItem = new ListViewItem(); myItem.Text = myReader["ndt_name"].ToString(); myItem.ImageIndex = 0; myItem.SubItems.Add(myReader["ndt_sjdw"].ToString()); myItem.SubItems.Add(myReader["ndt_jsr"].ToString()); lvndtdes.Items.Add(myItem); } myReader.Close(); }
private void timer1_Tick(object sender, EventArgs e) { con_ndt myObj = new con_ndt(); tvndtlist.Nodes.Clear(); _UserID = loginfrm.UserID; myObj.UserID = UserID; OleDbDataReader myReader = myObj.GetAllCONNDTDR(); while (myReader.Read()) { //先清除原先加载的,防止重复加载 TreeNode myNode = new TreeNode(myReader["ndt_no"].ToString(), 1, 2); con_ndt myCat = new con_ndt(); myCat.ndt_id = (int)myReader["ndt_id"]; myCat.ndt_no = myReader["ndt_no"].ToString(); myNode.Tag = myCat; tvndtlist.Nodes.Add(myNode); } myReader.Close(); //注意修改状态!! this.timer1.Enabled = false; }