在进行树节点多个拖拽的过程中,思路是这样的:先在Tree_DragEnter 事件里缓存下 需要拖拽的节点,然后再Tree_DragDrop 事件进行节点处理:
TreeListHitInfo hitinfo = uxTreeList1.Tree.CalcHitInfo(uxTreeList1.Tree.PointToClient(new Point(e.X, e.Y))); TreeListNode node = hitinfo.Node;//当前需要拖拽到的节点 DataTable dt_Src = this.uxTreeList1.Tree.DataSource as DataTable; List<DataRow> Lst_CCODE = dt_Src.AsEnumerable().Where(r => r["PCODE"].ToString() == CODE).ToList(); string MAXCODE = Lst_CCODE.Count>0?Lst_CCODE.Max(r => r["CODE"].ToString()):null; foreach (MoveNode MNODE in Lst_Move_Node) { int length = MNODE.CODE.Length; List<DataRow> Lst_MNODEROW = dt_Src.AsEnumerable().Where(r => r["CODE"].ToString().StartsWith(MNODE.CODE) && r["CODE"].ToString().Length >= length).ToList(); DataRow FCODEROW = Lst_MNODEROW.Where(r => r["CODE"].ToString() == MNODE.CODE).FirstOrDefault(); DataRow NEWROW = dt_Src.NewRow(); NEWROW.ItemArray = FCODEROW.ItemArray; NEWROW["PCODE"] = CODE; MAXCODE = string.IsNullOrEmpty(MAXCODE) ? string.Format("{0}0001", CODE) : (Convert.ToInt64(MAXCODE) + 1).ToString().PadLeft((CODE.Length + 4), '0'); NEWROW["CODE"] = MAXCODE; dt_Src.Rows.Remove(FCODEROW); dt_Src.Rows.Add(NEWROW); Lst_MNODEROW.Remove(FCODEROW); dt_Src.AcceptChanges(); SetChildNodes(MNODE.CODE, Lst_MNODEROW, NEWROW["CODE"].ToString()); } DataTable dt = dt_Src.Clone(); foreach (DataRow item in dt_Src.Rows) { dt.Rows.Add(item.ItemArray); } ///设定数据源
this.uxTreeList1.SetDataSource(INMR_DB_LEVEL_Common.CODE, INMR_DB_LEVEL_Common.PCODE, INMR_DB_LEVEL_Common.NODECAPTION, INMR_DB_LEVEL_Common.CODE, dt);
在实际的拖拽过程中出现了
在操作中没有选择cpi权重,可还是移动了,为什么呢