• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TreeView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TreeView的典型用法代码示例。如果您正苦于以下问题:C# TreeView类的具体用法?C# TreeView怎么用?C# TreeView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TreeView类属于命名空间,在下文中一共展示了TreeView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Run

    public void Run(string[] args)
    {
        Application.Init ();
        PopulateStore ();
        store.SetSortColumnId(2, SortType.Ascending);

        Window win = new Window ("Gtk Widget Attributes");
        win.DeleteEvent += new DeleteEventHandler (DeleteCB);
        win.SetDefaultSize (640,480);

        ScrolledWindow sw = new ScrolledWindow ();
        win.Add (sw);

        TreeView tv = new TreeView (store);
        tv.HeadersVisible = true;

        tv.AppendColumn ("Name", new CellRendererText (), "markup", 0);
        tv.AppendColumn ("Type", new CellRendererText (), "text", 1);

        foreach(TreeViewColumn col in tv.Columns)
            col.Resizable = true;

        tv.SearchColumn = 2;

        sw.Add (tv);

        dialog.Destroy ();
        dialog = null;

        win.ShowAll ();

        Application.Run ();
    }
开发者ID:langpavel,项目名称:LPS-old,代码行数:33,代码来源:Main.cs


示例2: MainForm

	public MainForm ()
	{
		// 
		// _tree
		// 
		_tree = new TreeView ();
		_tree.Dock = DockStyle.Top;
		_tree.Height = 100;
		Controls.Add (_tree);
		// 
		// _refreshButton
		// 
		_refreshButton = new Button ();
		_refreshButton.Location = new Point (8, 110);
		_refreshButton.Text = "Refresh";
		_refreshButton.Click += new EventHandler (RefreshButton_Click);
		Controls.Add (_refreshButton);
		// 
		// _visibleText
		// 
		_visibleText = new TextBox ();
		_visibleText.Dock = DockStyle.Bottom;
		_visibleText.Height = 200;
		_visibleText.Multiline = true;
		_visibleText.ScrollBars = ScrollBars.Vertical;
		Controls.Add (_visibleText);
		// 
		// MainForm
		// 
		ClientSize = new Size (400, 350);
		Location = new Point (250, 100);
		StartPosition = FormStartPosition.Manual;
		Text = "bug #81422";
		Load += new EventHandler (MainForm_Load);
	}
开发者ID:mono,项目名称:gert,代码行数:35,代码来源:MainForm.cs


示例3: Items_Should_Be_Created_Using_ItemTemplate_If_Present

        public void Items_Should_Be_Created_Using_ItemTemplate_If_Present()
        {
            TreeView target;

            var root = new TestRoot
            {
                Child = target = new TreeView
                {
                    Template = CreateTreeViewTemplate(),
                    Items = CreateTestTreeData(),
                    ItemTemplate = new FuncTreeDataTemplate<Node>(
                        _ => new Canvas(),
                        x => x.Children),
                }
            };

            ApplyTemplates(target);

            var items = target.ItemContainerGenerator.Index.Items
                .OfType<TreeViewItem>()
                .ToList();

            Assert.Equal(4, items.Count);
            Assert.All(items, x => Assert.IsType<Canvas>(x.HeaderPresenter.Child));
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:25,代码来源:TreeViewTests.cs


示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        #region Initialize Values
        Page mainPage = this.Page;
        myTree = (TreeView)mainPage.FindControl("TreeView1");
        NodeSelected = myTree.SelectedNode;

        btnSubmit.Text = CareerCruisingWeb.CCLib.Common.Strings.TextCode(11202);

        if (NodeSelected == null)
            return;

        if (NodeSelected.ToolTip == "Degree Requirement")
        {
            this.Visible = true;
            lblTitle.Text = NodeSelected.Text;
            strDegreeReqID = NodeSelected.Value;
            strDegreeID = NodeSelected.Parent.Value;
            strSchoolID = ((CareerCruisingWeb.PageBase.SuperBase)Page).SchoolID;
            HiddenField strLastNode = (HiddenField)mainPage.FindControl("hdnLastNode");

            if (strLastNode.Value != "DRID" + strDegreeReqID)
            {
                blFirstLoad = true;
                strLastNode.Value = "DRID" + strDegreeReqID;
            }
        }

        #endregion Initialize Values
    }
开发者ID:nehawadhwa,项目名称:ccweb,代码行数:30,代码来源:DegreeRequirement.ascx.cs


示例5: GetTreeView

    public static void GetTreeView(TreeView tv)
    {
        tv.Nodes.Clear();

        //建立根節點
        TreeNode Root = new TreeNode();
        Root.Text = "Land Project";
        tv.Nodes.Add(Root);//建立根节点

        using (SqlConnection cn = new SqlConnection(ConnString))
        {
            if (cn.State != ConnectionState.Open) cn.Open();
            using (SqlCommand cm = new SqlCommand(" Select Distinct Pid,Convert(Nvarchar(10),CreateTime) CreateTime From LandProject Order By CreateTime DESC", cn))
            {
                using (SqlDataReader dr = cm.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        TreeNode Node = new TreeNode();

                        Node.Text = dr["CreateTime"].ToString().Trim();
                        //Node.Target = "mainbottom";
                        //string Path = drNode["menu_addr"].ToString();
                        //int menusn = Convert.ToInt32(drNode["sn"].ToString());
                        Node.NavigateUrl = "LandProjectView.aspx" + "?Pid=" + dr["Pid"].ToString().Trim();
                        Root.ChildNodes.Add(Node);//建立子节点
                    }
                }
            }
        }
        tv.ExpandAll();
    }
开发者ID:jnss1980,项目名称:DASHAN,代码行数:32,代码来源:sidebar.cs


示例6: LoadHierarchicalXmlData

        // Load hierarchical data from XML and display it in a TreeListControl
        void LoadHierarchicalXmlData()
        {
 
            var treeListControl = new TreeListControl();
      
            treeListControl.Dock = DockStyle.Fill;
            treeListControl.ShowRoot = false;
            treeListControl.LabelEditMode = TreeControl.LabelEditModes.EditOnF2 | TreeControl.LabelEditModes.EditOnClick;
            treeListControl.NodeDataEdited += treeListControl_NodeDataEdited;
            Controls.Add(treeListControl);

            Assembly assembly = Assembly.GetExecutingAssembly();
            string startupPath = Path.GetDirectoryName(new Uri(assembly.GetName().CodeBase).LocalPath);
            var xmlPath = Path.Combine(startupPath, "CoolSUVs.xml");

            var treeView = new TreeView(xmlPath, new DataEditorTheme(treeListControl.Font));
            var treeControlAdapter = new TreeControlAdapter(treeListControl);
            treeControlAdapter.TreeView = treeView;

            treeListControl.ItemRenderer = new TreeListItemRenderer(treeView);

            treeListControl.Columns.Add(new TreeListView.Column("MPG",  80));
            treeListControl.Columns.Add(new TreeListView.Column("Weight", 80));
            treeListControl.Columns.Add(new TreeListView.Column("AWD", 50));
            treeListControl.Columns.Add(new TreeListView.Column("Color", 80));
            treeListControl.Columns.Add(new TreeListView.Column("MSRP", 80));
            treeListControl.ExpandAll();
        }
开发者ID:sbambach,项目名称:ATF,代码行数:29,代码来源:Form1.cs


示例7: Init

 public void Init(Rect rect, BackendData backendData)
 {
   if (this.m_TreeView != null)
     return;
   this.m_BackendData = backendData;
   TreeViewState treeViewState = new TreeViewState();
   treeViewState.columnWidths = new float[6]
   {
     250f,
     90f,
     93f,
     98f,
     74f,
     78f
   };
   this.m_TreeView = new TreeView(this.m_EditorWindow, treeViewState);
   ITreeViewGUI gui = (ITreeViewGUI) new TestGUI(this.m_TreeView);
   ITreeViewDragging dragging = (ITreeViewDragging) new TestDragging(this.m_TreeView, this.m_BackendData);
   ITreeViewDataSource data = !this.m_Lazy ? (ITreeViewDataSource) new TestDataSource(this.m_TreeView, this.m_BackendData) : (ITreeViewDataSource) new LazyTestDataSource(this.m_TreeView, this.m_BackendData);
   this.m_TreeView.Init(rect, data, gui, dragging);
   this.m_ColumnHeader = new TreeViewColumnHeader();
   this.m_ColumnHeader.columnWidths = treeViewState.columnWidths;
   this.m_ColumnHeader.minColumnWidth = 30f;
   this.m_ColumnHeader.columnRenderer += new System.Action<int, Rect>(this.OnColumnRenderer);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:25,代码来源:TreeViewTest.cs


示例8: MForm9

    public MForm9()
    {
        Text = "TreeView";
        Size = new Size(250, 250);

        TreeView tv = new TreeView();

        TreeNode root = new TreeNode();
        root.Text = "Languages";

        TreeNode child1 = new TreeNode();
        child1.Text = "Python";

        TreeNode child2 = new TreeNode();
        child2.Text = "Ruby";

        TreeNode child3 = new TreeNode();
        child3.Text = "Java";

        root.Nodes.AddRange(new TreeNode[] {child1, child2, child3});

        tv.Parent = this;
        tv.Nodes.Add(root);
        tv.Dock = DockStyle.Fill;
        tv.AfterSelect += new TreeViewEventHandler(AfterSelect);

        sb = new StatusBar();
        sb.Parent = this;

        CenterToScreen();
    }
开发者ID:sciruela,项目名称:MonoWinformsTutorial,代码行数:31,代码来源:treeview.cs


示例9: Tree

    public Tree(string[] args)
    {
        Application.Init ();

        store = new TreeStore (typeof (string), typeof (string));

        Glade.XML gxml = new Glade.XML(null, "tree.glade", "window", null );
        gxml.Autoconnect( this );

        window.Resize(500, 400 );
        // eventos
        window.DeleteEvent += new DeleteEventHandler( Salir );
        b_agregar.Clicked += new EventHandler( Agregar );
        b_eliminar.Clicked += new EventHandler( Borrar );
        b_limpiar.Clicked += new EventHandler( Limpiar );
        b_salir.Clicked += new EventHandler( Cerrar );

        // crear arbol

        tv = new TreeView ();
        tv.Model = store;
        tv.HeadersVisible = true;

        tv.AppendColumn ("Nombre", new CellRendererText (), "text", 0);
        tv.AppendColumn ("Apellidos", new CellRendererText (), "text", 1);

        scrolledwindow1.Add (tv);
        window.ShowAll ();
        Application.Run ();
    }
开发者ID:BackupTheBerlios,项目名称:boxerp-svn,代码行数:30,代码来源:tree.cs


示例10: SaveTreeView

    public void SaveTreeView(TreeView treeView, string key)
    {

        List<bool?> list = new List<bool?>();
        SaveTreeViewExpandedState(treeView.Nodes, list);
        HttpContext.Current.Session[key + treeView.ID] = list;
    }
开发者ID:jackiechou,项目名称:thegioicuaban.com,代码行数:7,代码来源:TreeViewState.cs


示例11: Root_TreeContainerFromItem_Should_Return_Descendent_Item

        public void Root_TreeContainerFromItem_Should_Return_Descendent_Item()
        {
            var tree = CreateTestTreeData();
            var target = new TreeView
            {
                Template = CreateTreeViewTemplate(),
                Items = tree,
                DataTemplates = CreateNodeDataTemplate(),
            };

            // For TreeViewItem to find its parent TreeView, OnAttachedToLogicalTree needs
            // to be called, which requires an IStyleRoot.
            var root = new TestRoot();
            root.Child = target;

            ApplyTemplates(target);

            var container = target.ItemContainerGenerator.Index.ContainerFromItem(
                tree[0].Children[1].Children[0]);

            Assert.NotNull(container);

            var header = ((TreeViewItem)container).Header;
            var headerContent = ((TextBlock)header).Text;

            Assert.Equal("Grandchild2a", headerContent);
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:27,代码来源:TreeViewTests.cs


示例12: readSysTree

 public void readSysTree(TreeView TV)
 {
     Model.SelectRecord selectRecord = new Model.SelectRecord("Menu", "", "*", "where 1=1");
     DataSet set = BLL.SelectRecord.SelectRecordData(selectRecord);
     if (set != null)
     {
         DataTable table = set.Tables[0];
         TV.Nodes.Clear();
         DataView view3 = new DataView(table)
         {
             RowFilter = "parentid=0"
         };
         DataView view = view3;
         foreach (DataRowView view2 in view)
         {
             TreeNode node2 = new TreeNode
             {
                 Text = view2["name"].ToString(),
                 Value = view2["id"].ToString()
             };
             TreeNode child = node2;
             if (this.list.Contains(view2["id"].ToString()))
             {
                 child.Checked = true;
             }
             TV.Nodes.Add(child);
             this.AddChildNode(table, child, view2["id"].ToString());
             child.ExpandAll();
         }
     }
 }
开发者ID:xiluo,项目名称:document-management,代码行数:31,代码来源:Authorize.aspx.cs


示例13: SelectTreeNodeByNodeValue

 public static void SelectTreeNodeByNodeValue(TreeView treeView, string nodeValue)
 {
     foreach (TreeNode rootNode in treeView.Nodes) {
         bool isSelected = SelectTreeNodeByNodeValue(treeView, rootNode, nodeValue);
         if (isSelected) break;
     }
 }
开发者ID:hijoy,项目名称:VSL_ERS,代码行数:7,代码来源:PageUtility.cs


示例14: Checked

      protected override bool Checked(WinForms::ToolStripMenuItem clickedItem, TreeView treeView, TreeNode clickedTn)
      {
         IEnumerable<IMaxNode> selNodes = TreeMode.GetMaxNodes(treeView.SelectedNodes);

         return selNodes.OfType<XRefSceneRecord>()
                        .Any(x => x.HasFlags(this.Flags));
      }
开发者ID:Sugz,项目名称:Outliner-3.0,代码行数:7,代码来源:SetXRefSceneFlagItemModel.cs


示例15: Populate

    public TreeView Populate(string userId)
    {
        TreeView treeView = new TreeView();

        IList<MenuFuncVO> menuFuncList = m_AuthService.GetTopMenuFuncNoLazy();

        //var result = from data in menuFuncList
        //             where data.ParentMenu == null
        //             select data;

        foreach (MenuFuncVO menu in menuFuncList)
        {
            TreeNode treeNode = new TreeNode(menu.MenuFuncName, "");

            if (menu.SubFuncs.Count > 0)
            {
                foreach (MenuFuncVO subMenu in menu.SubFuncs)
                {
                    //TreeNode subTreeNode = new TreeNode(subMenu.MenuFuncName, subMenu.Id.ToString());
                    TreeNode subTreeNode = new TreeNode(subMenu.MenuFuncName, subMenu.MainPath);
                    //subTreeNode.NavigateUrl = "~/" + subMenu.MainPath;
                    treeNode.ChildNodes.Add(subTreeNode);
                }
            }

            treeView.Nodes.Add(treeNode);
        }
        return treeView;
    }
开发者ID:dada2cindy,项目名称:my-case-petemobile,代码行数:29,代码来源:TreeveiwService.cs


示例16: SetupTree

            private void SetupTree()
            {
                tree = new TreeView ();
                this.store = new ListStore (typeof (object));
                tree.Model = store;

                TreeViewColumn col = new TreeViewColumn ();
                col.Sizing = TreeViewColumnSizing.Fixed;
                col.Spacing = 4;

                CellRendererText text_renderer =
                    new CellRendererText ();
                text_renderer.WrapMode = Pango.WrapMode.Word;
                col.PackStart (text_renderer, true);
                col.SetCellDataFunc (text_renderer,
                             new
                             TreeCellDataFunc
                             (PluginInfoCellDataFunc));

                CellRendererToggle loaded_renderer =
                    new CellRendererToggle ();
                loaded_renderer.Activatable = false;
                col.PackStart (loaded_renderer, false);
                col.SetCellDataFunc (loaded_renderer,
                             new
                             TreeCellDataFunc
                             (LoadedStatusCellDataFunc));

                col.Title = Catalog.GetString("Plugins Details");
                tree.AppendColumn (col);
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:31,代码来源:PluginManagerDialog.cs


示例17: TreeViewDemo

    public TreeViewDemo()
    {
        Application.Init ();
        PopulateStore ();

        Window win = new Window ("TreeView demo");
        win.DeleteEvent += new DeleteEventHandler (DeleteCB);
        win.SetDefaultSize (640,480);

        ScrolledWindow sw = new ScrolledWindow ();
        win.Add (sw);

        TreeView tv = new TreeView (store);
        tv.EnableSearch = true;
        tv.HeadersVisible = true;
        tv.HeadersClickable = true;

        tv.AppendColumn ("Name", new CellRendererText (), "text", 0);
        tv.AppendColumn ("Type", new CellRendererText (), "text", 1);

        sw.Add (tv);

        dialog.Destroy ();
        dialog = null;

        win.ShowAll ();

        Application.Run ();
    }
开发者ID:numerodix,项目名称:nametrans,代码行数:29,代码来源:TreeViewDemo.cs


示例18: TreeStyle

        public TreeStyle(TreeView tree)
        {
            _tree = tree;
            _frozenFont = new Font(_tree.Font, FontStyle.Italic);

            NodeForeColor = SystemColors.WindowText;
            NodeBackColor = SystemColors.Window;
            FrozenForeColor = SystemColors.GrayText;
            FrozenBackColor = SystemColors.Window;
            HiddenForeColor = SystemColors.GrayText;
            HiddenBackColor = SystemColors.Window;
            XrefForeColor = SystemColors.WindowText;
            XrefBackColor = SystemColors.Window;

            SelectionForeColor = SystemColors.HighlightText;
            SelectionBackColor = SystemColors.Highlight;

            LinkForeColor = SystemColors.WindowText;
            LinkBackColor = Color.FromArgb(255, 177, 177);

            ParentForeColor = SystemColors.WindowText;
            ParentBackColor = Color.FromArgb(177, 255, 177);

            LayerForeColor = SystemColors.WindowText;
            LayerBackColor = Color.FromArgb(177, 228, 255);
        }
开发者ID:Pjanssen,项目名称:Outliner,代码行数:26,代码来源:TreeStyle.cs


示例19: DataContexts_Should_Be_Correctly_Set

        public void DataContexts_Should_Be_Correctly_Set()
        {
            var items = new object[]
            {
                "Foo",
                new Node { Value = "Bar" },
                new TextBlock { Text = "Baz" },
                new TreeViewItem { Header = "Qux" },
            };

            var target = new TreeView
            {
                Template = CreateTreeViewTemplate(),
                DataContext = "Base",
                DataTemplates = new DataTemplates
                {
                    new FuncDataTemplate<Node>(x => new Button { Content = x })
                },
                Items = items,
            };

            ApplyTemplates(target);

            var dataContexts = target.Presenter.Panel.Children
                .Cast<Control>()
                .Select(x => x.DataContext)
                .ToList();

            Assert.Equal(
                new object[] { items[0], items[1], "Base", "Base" },
                dataContexts);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:32,代码来源:TreeViewTests.cs


示例20: TreeViewRenderingTests

        public TreeViewRenderingTests()
        {
            Mock<TextWriter> textWriter = new Mock<TextWriter>();
            Mock<HtmlTextWriter> writer = new Mock<HtmlTextWriter>(textWriter.Object);
            objectWriter = new Mock<IClientSideObjectWriter>();

            var list = new List<IHtmlNode>();
            list.Add(new HtmlElement("div"));

            var rootTag = new Mock<IHtmlNode>();
            rootTag.SetupGet(t => t.Children).Returns(() => list);

            var itemTag = new Mock<IHtmlNode>();
            itemTag.SetupGet(t => t.Children).Returns(() => list);
            itemTag.Setup(t => t.AppendTo(It.IsAny<IHtmlNode>())).Returns(() => itemTag.Object);

            builder = new Mock<ITreeViewHtmlBuilder>();
            builder.Setup(r => r.TreeViewTag()).Returns(() => rootTag.Object);
            builder.Setup(r => r.ItemTag(It.IsAny<TreeViewItem>(), It.IsAny<bool>())).Returns(() => itemTag.Object);
            builder.Setup(r => r.ItemInnerContent(It.IsAny<TreeViewItem>())).Returns(() => new Mock<IHtmlNode>().Object);
            builder.Setup(r => r.ItemHiddenInputValue(It.IsAny<TreeViewItem>())).Returns(() => new Mock<IHtmlNode>().Object);
            builder.Setup(r => r.ItemContentTag(It.IsAny<TreeViewItem>())).Returns(() => new Mock<IHtmlNode>().Object);
            builder.Setup(r => r.ChildrenTag(It.IsAny<TreeViewItem>())).Returns(() => new Mock<IHtmlNode>().Object);

            treeView = TreeViewTestHelper.CreateTreeView(writer.Object, builder.Object, objectWriter.Object);
            treeView.Name = "TreeView";
        }
开发者ID:vialpando09,项目名称:RallyPortal2,代码行数:27,代码来源:TreeViewRenderingTests.cs



注:本文中的TreeView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TreeViewItem类代码示例发布时间:2022-05-24
下一篇:
C# TreeStore类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap