Animation效果的树状(treeView)控件源代码

感谢网友的支持,有的网友说用不了,所以在这里我又重新做了一个修改,把详细的使用方法写出来

第一步

拷贝文件到你的项目中,下载源代码后你会发现有很多项目,有的童鞋会感觉很乱,不要乱,让我一解释一下吧

这个开源代码有很多控件,这里我只说树控件。首先拷贝BinaryComponents.SuperTree,BinaryComponents.Utility,BinaryComponents.WinFormsUtility,这三个文件到你的项目中

第一个是BinaryComponents.SuperTre就是我们要用到的树控件,其他两个就是要用到的类

第二步

把这三个项目添加到你的项目中并且添加引用

添加项目方法:右键你的解决方案->添加-.现有项目

如下图

然后找到刚才拷贝的这三个项并按顺序添加

来看一下添加后的效果吧

这样就是添加成功了

现在添加完还不行,要做项目引用

首先添加表现层的引用,也就是有WEIN窗体的那一层,不知道我这样说你明不明,这里我的叫WindowsFormsApplication1,是默认的,我并没有修改

右键引用->添加引用,如下图片

选择“项目”选项卡,你会看到你刚才添加的两个项目,这里你选择BinaryComponents.SuperTree和BinaryComponents.Utility就可以

OK这一层的添加完成

以同样的方法添加BinaryComponents.SuperTree层,引用对像是BinaryComponents.Utility和BinaryComponents.WinFormsUtility

现在引用是完成了

这时后你会发现你的VS工具箱中多了很多控件,如下图

这里我们只用到了TreeControl,拖动这个控件到你的窗体中

就可以了

最还要要拷贝个文件就是SuperTreeTest中的Resources,这里是图标文件,然后要把里面的3个ICO文件设置成内嵌的资源

设置方法,右键图片属性里

还要注意一个地方就是绑定方法里,

BinaryComponents.Utility.Assemblies.ManifestResources res = new BinaryComponents.Utility.Assemblies.ManifestResources("WindowsFormsApplication1");

其中最后面的WindowsFormsApplication1要改成你的项目名名称

就写到这了,我把刚才测试代码传上去了,可以下载

控件的animage 属性=TRUE时有渐渐展开效果

现在给大家一个代码是绑定的,不过是有限制的,自己可以写一个无限绑定的吗

private void FillTreeControl( BinaryComponents.SuperTree.TreeControl treeControl )
{
BinaryComponents.Utility.Assemblies.ManifestResources res
= new BinaryComponents.Utility.Assemblies.ManifestResources( "SuperTreeTest" );

using( treeControl.SuspendUpdates() )
{
treeControl.Icons.Add( res.GetIcon(
"Resources.FeedTreeItem16.ico" ) );
treeControl.Icons.Add( res.GetIcon(
"Resources.CollapsedFolderTreeItem16.ico" ) );
treeControl.Icons.Add( res.GetIcon(
"Resources.ExpandedFolderTreeItem16.ico" ) );

for( int x = 1; x <= 5; ++x )
{
BinaryComponents.SuperTree.TreeNode xtn
= treeControl.RootNodes.Add();

xtn.Text
= string.Format( "Folder - X - {0}", x );
xtn.ExpandedImageIndex
= 2;
xtn.CollapsedImageIndex
= 1;

for( int y = 1; y <= 5; ++y )
{
BinaryComponents.SuperTree.TreeNode ytn
= xtn.ChildNodes.Add();

ytn.Text
= string.Format( "Folder - Y - {0}", y );
ytn.ExpandedImageIndex
= 2;
ytn.CollapsedImageIndex
= 1;

for( int z = 1; z <= 5; ++z )
{
BinaryComponents.SuperTree.TreeNode ztn
= ytn.ChildNodes.Add();

ztn.Text
= string.Format( "Subscription - Z - {0}", z );
ztn.ExpandedImageIndex
= 0;
ztn.CollapsedImageIndex
= 0;
}
}
}
}
}

调用方法

FillTreeControl(treeControl1);

下载地址:http://www.51ascx.com/68.html

posted @ 2011-04-06 09:12  小眼睛Smile  阅读(1808)  评论(7编辑  收藏  举报