当前位置:首页 > 网络编程 > 软件语言 > DELPHI > Delphi 4中TTreeView的bug

Delphi 4中TTreeView的bug

点击次数:51 次 发布日期:2008-11-09 08:38:44 作者:源代码网
源代码网推荐
广告载入中
假设我们要将某个结点treenode移动到另一结点AnItem上并做为AnItem的child,按照文档说明,只需这样做
源代码网推荐 TreeNode.moveto(AnItem,nrAddChild);
源代码网推荐 但实际上,在Delphi 4中,假如anode原来没有child的话,这条语句将不做任何事情。折衷的办法是
源代码网推荐 TempNode:=TopicTV.items.AddChild(AnItem,"");
源代码网推荐 TreeNode.MoveTo(TempNode, naInsert);
源代码网推荐 TempNode.free;
源代码网推荐 在Tipexplr程序的源码中,关于实现同样操作,它指出,Delphi的TTreeView有bug,并提供了自己的解决方法(见下),但这只能在Delphi 3中通过,在Delphi 4中,只能用我的上面的方法。
源代码网推荐 AttachMode := naAddChild; { Add tip as a child of category }
源代码网推荐
源代码网推荐 { Note: Adding the temporary node is a work around to a bug }
源代码网推荐 { that exists in the TreeView component when moving a }
源代码网推荐 { node to a another node that doesn"t have any children }
源代码网推荐
源代码网推荐 TempNode := TvwTips.Items.AddChild( TvwTips.DropTarget,"Temp" );
源代码网推荐 try
源代码网推荐 { Move the node in the tree view }
源代码网推荐 TvwTips.Selected.MoveTo( TvwTips.DropTarget, AttachMode );
源代码网推荐
源代码网推荐 { Now need to update the category of tip in the database }


源代码网推荐 TblTips.DisableControls;
源代码网推荐 try
源代码网推荐 TblTips.Edit;
源代码网推荐 TblTips[ "Category" ] := TvwTips.DropTarget.Text;
源代码网推荐 TblTips.Post;
源代码网推荐 finally
源代码网推荐 TblTips.EnableControls;
源代码网推荐 end;
源代码网推荐
源代码网推荐 finally
源代码网推荐 TempNode.Free; { Don"t forget to release the temp node }
源代码网推荐 end;
软件开发网 www.mscto.com


源代码网推荐

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华