Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#:如何使用自定义TreeView对象?_C#_Asp.net_Treeview - Fatal编程技术网

C#:如何使用自定义TreeView对象?

C#:如何使用自定义TreeView对象?,c#,asp.net,treeview,C#,Asp.net,Treeview,如果您像这样创建自定义的TreeView和TreeNode: public class CustomTreeNode : TreeNode { private int customInt; public int CustomInt { get { return customInt; } set { customInt= value;

如果您像这样创建自定义的
TreeView
TreeNode

public class CustomTreeNode : TreeNode
{
    private int customInt;

    public int CustomInt
    {
        get
        {
            return customInt;
        }
        set
        {
            customInt= value;
        }
    }

}

public class CustomTreeView : TreeView
{
    protected override TreeNode CreateNode()
    {
        return new CustomTreeNode();
    }
}

我如何在代码中使用它?如何在我的aspx页面中使用此
TreeView

您必须将此代码放入App\u代码或将其构建到程序集中。然后在ASPX中,您需要一个@Register指令,它将包含新控件的名称空间。如果你把它放在App_代码中,程序集将是App_代码。然后,一旦包含它,您就可以在页面上使用定义的标记前缀创建它。我的意思是:

<%@ Page Language="C#"%>
<%@ Register Assembly="MyBuiltAssembly" Namespace="CustomTreeViewNamespace" TagPrefix="test" %>



这和您前面的问题一样吗?不,那是关于treenode的。这是如何使用自定义树视图
<test:CustomTreeView ID="CustomTreeView1" runat="server">