View all Assembly Form Type and its members in a Tree : Assembly « Development « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Development » AssemblyScreenshots 
View all Assembly Form Type and its members in a Tree
 
Imports System
Imports System.Drawing
Imports System.Reflection
Imports System.Windows.Forms

public class MainClass

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

End Class



Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is NothingThen
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents treeView1 As System.Windows.Forms.TreeView

    '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()
        Me.treeView1 = New System.Windows.Forms.TreeView()
        Me.SuspendLayout()
        '
        'treeView1
        '
        Me.treeView1.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom_
                    Or System.Windows.Forms.AnchorStyles.Left_
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.treeView1.ImageIndex = -1
        Me.treeView1.Location = New System.Drawing.Point(816)
        Me.treeView1.Name = "treeView1"
        Me.treeView1.SelectedImageIndex = -1
        Me.treeView1.Size = New System.Drawing.Size(448200)
        Me.treeView1.Sorted = True
        Me.treeView1.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(467248)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.treeView1})
        Me.Name = "Form1"
        Me.Text = "View Direct Members of Objects"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private Function StripType(ByVal s As StringAs String
        Dim spacepos As Integer
        spacepos = InStr(s, " ")
        If spacepos > Then Return Mid$(s, spacepos + 1)
        Return (s)
    End Function

    Private Sub Form1_Load(ByVal sender As Object, _
        ByVal e As System.EventArgsHandles Me.Load
        Dim asm As [Assembly]
        Dim asmtypes() As Type
        Dim ThisType As Type
        asm = Reflection.Assembly.GetAssembly(GetType(System.Windows.Forms.Form))
        asmtypes = asm.GetTypes()
        For Each ThisType In asmtypes
            If ThisType.IsClass Then
                Dim tn As New TreeNode(ThisType.Name)
                Dim members(), mi As MemberInfo
                treeView1.Nodes.Add(tn)
                members = ThisType.GetMembers(BindingFlags.DeclaredOnly Or BindingFlags.Public Or BindingFlags.Instance Or BindingFlags.Static)
                For Each mi In members
                    Dim methinfo As MethodInfo
                    Select Case mi.MemberType
                        Case MemberTypes.Method
                            methinfo = CType(mi, MethodInfo)
                            If Not methinfo.IsSpecialName Then
                                tn.Nodes.Add(StripType(mi.ToString))
                            End If
                        Case MemberTypes.Event
                            tn.Nodes.Add(StripType(mi.ToString" event")
                        Case Else
                            tn.Nodes.Add(StripType(mi.ToString))
                    End Select
                Next
            End If
        Next
    End Sub


End Class

           
         
  
Related examples in the same category
1.Add all Public Assembly Form TypeAdd all Public Assembly Form Type
2.View all Assembly Form Type in a TreeView all Assembly Form Type in a Tree
3.Find Members with Binding FlagsFind Members with Binding Flags
4.Get Assembly Member type: Property or Member Get Assembly Member type: Property or Member
5.Load all Types in one AssemblyLoad all Types in one Assembly
6.Get Class Name in Current AssemblyGet Class Name in Current Assembly
7.Get Executing AssemblyGet Executing Assembly
8.Get Information from AssemblyGet Information from Assembly
9.Get info for current AppDomain
10.Hook into DomainUnload event
11.Programmatically make a new app domain
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.