当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET TreeView.ExpandAll方法代码示例

本文整理汇总了VB.NET中System.Windows.Forms.TreeView.ExpandAll方法的典型用法代码示例。如果您正苦于以下问题:VB.NET TreeView.ExpandAll方法的具体用法?VB.NET TreeView.ExpandAll怎么用?VB.NET TreeView.ExpandAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TreeView的用法示例。


在下文中一共展示了TreeView.ExpandAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1:

Private Sub myCheckBox_CheckedChanged(ByVal sender As Object, _
   ByVal e As System.EventArgs) Handles myCheckBox.CheckedChanged
   ' If the check box is checked, expand all the tree nodes.
   If myCheckBox.Checked = True Then
      myTreeView.ExpandAll()
   Else
      ' If the check box is not checked, collapse the first tree node.
      myTreeView.Nodes(0).FirstNode.Collapse()
      MessageBox.Show("The first node of CustomerList root node is collapsed")
   End If
End Sub
开发者ID:VB.NET开发者,项目名称:System.Windows.Forms,代码行数:11,代码来源:TreeView.ExpandAll

示例2: TreeView.ExpandAll()

' 导入命名空间
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Data.SqlClient

public class MainClass
   Shared Sub Main()
       Dim form1 As Form = New Form1
       Application.Run(form1)
   End Sub
End Class


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim factory, group, person As TreeNode

        ' Create some nodes.
        trvOrgChart.Nodes.Clear()
        factory = trvOrgChart.Nodes.Add("f Name", "Name", 0, 0)
        group = factory.Nodes.Add("g Dept 1", "Dept 2", 1, 1)
        person = group.Nodes.Add("p Name 1", "Name 1", 2, 2)
        person = group.Nodes.Add("p Name 2", "Name 2", 2, 2)

        group = factory.Nodes.Add("g Dep 2", "Dep 2t", 1, 1)
        person = group.Nodes.Add("p Name 1", "Name 1", 2, 2)
        person = group.Nodes.Add("p Name 2", "Name 2", 2, 2)

        factory = trvOrgChart.Nodes.Add( _
            "f Dept 3", "Dept 3", 0, 0)
        group = factory.Nodes.Add( _
            "g Name 1", "Name 1", 1, 1)
        person = group.Nodes.Add( _
            "p Name 2", "Name 2", 2, 2)
        person = group.Nodes.Add( _
            "p Name 3", "Namr 3", 2, 2)

        group = factory.Nodes.Add( _
            "g Dep 5", "Dep 5", 1, 1)
        person = group.Nodes.Add( _
            "p Name 1", "Name 1", 2, 2)
        person = group.Nodes.Add( _
            "p Name 2", "Namr 2", 2, 2)
        person = group.Nodes.Add( _
            "p Name 3", "Name 3", 2, 2)

        group = factory.Nodes.Add( _
            "g Dept 10", "Dept 10", 1, 1)
        person = group.Nodes.Add( _
            "p Name 1", "Namr 1", 2, 2)
        person = group.Nodes.Add( _
            "p Namr 2", "Name 2", 2, 2)

        trvOrgChart.ExpandAll()
        trvOrgChart.Nodes(0).EnsureVisible()
    End Sub

    Private Sub trvOrgChart_BeforeLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles trvOrgChart.BeforeLabelEdit
        e.CancelEdit = (e.Node.FullPath.IndexOf(trvOrgChart.PathSeparator) = -1)
    End Sub
End Class



<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Public Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Dim TreeNode1 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Cameron, Charlie", 2, 5)
        Dim TreeNode2 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Davos, Debbie", 2, 5)
        Dim TreeNode3 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Engineering", 1, 4, New System.Windows.Forms.TreeNode() {TreeNode1, TreeNode2})
        Dim TreeNode4 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Test", 1, 4)
        Dim TreeNode5 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("R & D", 0, 3, New System.Windows.Forms.TreeNode() {TreeNode3, TreeNode4})
        Me.trvOrgChart = New System.Windows.Forms.TreeView
        Me.SuspendLayout()
        '
        'trvOrgChart
        '
        Me.trvOrgChart.Dock = System.Windows.Forms.DockStyle.Fill
        Me.trvOrgChart.ImageIndex = 0
        Me.trvOrgChart.LabelEdit = True
        Me.trvOrgChart.Location = New System.Drawing.Point(0, 0)
        Me.trvOrgChart.Name = "trvOrgChart"
        TreeNode1.Name = "Node6"
        TreeNode1.SelectedImageIndex = 5
        TreeNode1.Text = "Cameron, Charlie"
        TreeNode2.Name = "Node7"
        TreeNode2.SelectedImageIndex = 5
        TreeNode2.Text = "Davos, Debbie"
        TreeNode3.ImageIndex = 1
        TreeNode3.Name = "Node5"
        TreeNode3.SelectedImageIndex = 4
        TreeNode3.Text = "Engineering"
        TreeNode4.ImageIndex = 1
        TreeNode4.Name = "Node8"
        TreeNode4.SelectedImageIndex = 4
        TreeNode4.Text = "Test"
        TreeNode5.ImageIndex = 0
        TreeNode5.Name = "Node0"
        TreeNode5.SelectedImageIndex = 3
        TreeNode5.Text = "R & D"
        Me.trvOrgChart.Nodes.AddRange(New System.Windows.Forms.TreeNode() {TreeNode5})
        Me.trvOrgChart.SelectedImageIndex = 0
        Me.trvOrgChart.Size = New System.Drawing.Size(292, 273)
        Me.trvOrgChart.TabIndex = 1
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.trvOrgChart)
        Me.Name = "Form1"
        Me.Text = "UseTreeView"
        Me.ResumeLayout(False)

    End Sub

    Friend WithEvents trvOrgChart As System.Windows.Forms.TreeView

End Class
开发者ID:VB程序员,项目名称:System.Windows.Forms,代码行数:141,代码来源:TreeView.ExpandAll


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