Learnig构建树视图控件 [英] Learnig to Build a Tree View Control

查看:50
本文介绍了Learnig构建树视图控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道一篇讨论创建树查看的好文章。在ASP.NET中控制?或者可能是带有源代码的
树视图控件?我遇到了很多用于ASP.NET的树控件

但是大部分已经编译好了并且没有来源

代码。我真的只是在寻找一个如何创建自己的

Tree Control的例子。非常感谢。

解决方案

创建树视图控件与创建或设计

相同应用。您列举了一系列要求,查看可用的

工具和技术,找出满足您要求的内容,并且

想出一个计划。而不是看其他人如何解决这个问题的例子,为什么不把这看作是练习你的b $ b分析和设计技巧的机会呢?
< br $> b $ b -

HTH,

Kevin Spencer

Microsoft MVP

..Net开发商

你所寻求的是什么。


" dwok" <德*** @ wubbafish.net>在消息中写道

news:11 ********************* @ f14g2000cwb.googlegro ups.com ...

有没有人知道一篇讨论创建树
视图的好文章。在ASP.NET中控制?或者可能是带有源代码的树视图控件?我已经遇到了很多用于ASP.NET的树控件
但是它们中的大多数已经编译好了,并没有附带源代码。我真的只是在寻找一个如何创建自己的树控件的例子。非常感谢。



这非常简单。

虽然我没有时间详细了解如何它

是你应该熟悉的主题

使用Viewstate来存储你自己的变量。

创建可序列化的自定义类和deserialiazable

和Recursiveness


如果我是你,我会建立一个实现ICollection的自定义类。

这将被推荐从这里开始作为你的NodeCollection。

你将有另一个自定义类。这将从现在开始称为您的

节点。

两者都必须标记为Serializable。在

msdn库中查找此属性。

对于速度skae,您应该实现ISerializable并实现

特殊构造函数并添加和检索所有您的变量

手动。这需要更多代码,但提供了显着的性能

提升,因为它不需要在序列化时使用反射和

反序列化。


您的TreeNode将具有NodeCollection类型的属性。

您将覆盖LoadViewState和SaveViewState,并简单地将您的Tree的节点集合添加到viewstate所有内容序列化

自动并反序列化。你所要做的就是从Viewstate添加和检索




渲染只是递归的问题。

foreach(treenode in treenodecollection)

{

渲染节点

callself(treenode.Nodes)

}


希望这对任何方式都有帮助


像真正的MVP一样说话


Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don''t come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

解决方案

Creating a Tree View Control is the same as creating or designing an
application. You enumerate a set of requirements, look at the available
tools and technologies, figure out what will satisfy your requirements, and
come up with a plan. Rather than looking at examples of how other people
soved the problem, why not look at this as an opportunity to practice your
analysis and design skills?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"dwok" <de***@wubbafish.net> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...

Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don''t come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.



It is extremely simple.
While I do not have the time to go into greater detail regarding how it
is the topics you should be familiar with already are
Using the Viewstate to store your own variables.
Creating custom classes that are serializable and deserialiazable
and Recursiveness

if i were you i would build a custom class that implements ICollection.
This will be referred to as your NodeCollection from here on out.
You will have another custom class. This will be referred to as your
Node from here on out.
Both have to be marked as Serializable. Look up this Attribute in the
msdn library.
For speed skae you should implement ISerializable and implement the
special constructor and add and retrieve all of your variables
manually. This requires more code but offers a significate performance
boost as it doesnot have to use reflection when serializaing and
deserializing.

Your TreeNode will have a property that is of the type NodeCollection.
you will override LoadViewState and SaveViewState and by simply adding
your Tree''s Node Collection to the viewstate everything is serialized
automatically and deserialized. All you have to do is add and retrieve
it from the Viewstate.

Rendering is simply a matter of Recursive ness.
foreach (treenode in treenodecollection)
{
render node
callself(treenode.Nodes)
}

Hope this is helpful in any way


spoken like a true MVP


这篇关于Learnig构建树视图控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆