Fill Reflection Data into ListView : Reflection « Development « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VB.Net » Development » ReflectionScreenshots 
Fill Reflection Data into ListView
Fill Reflection Data into ListView

Imports System
Imports System.Collections
Imports System.Data
Imports System.Reflection
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.Drawing.Drawing2D
Imports System.IO

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.EventArgsHandles MyBase.Load
        ' Make column headers.
        lvwProperties.View = View.Details
        lvwProperties.Columns.Clear()
        lvwProperties.Columns.Add("Property"10, HorizontalAlignment.Left)
        lvwProperties.Columns.Add("Type"10, HorizontalAlignment.Left)
        lvwProperties.Columns.Add("Value"10,HorizontalAlignment.Left)

        Dim property_value As Object
        Dim properties_info As PropertyInfo() = GetType(Form1).GetProperties()
        lvwProperties.Items.Clear()
        For i As Integer = To properties_info.Length - 1
            With properties_info(i)
                If .GetIndexParameters().Length = Then
                    property_value = .GetValue(Me, Nothing)
                    If property_value Is Nothing Then
                        ListViewMakeRow(lvwProperties, _
                            .Name, _
                            .PropertyType.ToString, _
                            "<Nothing>")
                    Else
                        ListViewMakeRow(lvwProperties, _
                            .Name, _
                            .PropertyType.ToString, _
                            property_value.ToString)
                    End If
                Else
                    ListViewMakeRow(lvwProperties, _
                        .Name, _
                        .PropertyType.ToString, _
                        "<array>")
                End If
            End With
        Next i

        lvwProperties.Columns(0).Width = -2
        lvwProperties.Columns(1).Width = -2
        lvwProperties.Columns(2).Width = -2

        Dim new_wid As Integer = 30
        For i As Integer = To lvwProperties.Columns.Count - 1
            new_wid += lvwProperties.Columns(i).Width
        Next i
        Me.Size = New Size(new_wid, Me.Size.Height)
    End Sub

    Private Sub ListViewMakeRow(ByVal lvw As ListView, ByVal item_title As String, ByVal ParamArray subitem_titles() As String)
        Dim new_item As ListViewItem = lvw.Items.Add(item_title)
        For i As Integer = subitem_titles.GetLowerBound(0To _
            subitem_titles.GetUpperBound(0)
            new_item.SubItems.Add(subitem_titles(i))
        Next i
    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()
        Me.lvwProperties = New System.Windows.Forms.ListView
        Me.SuspendLayout()
        '
        'lvwProperties
        '
        Me.lvwProperties.Dock = System.Windows.Forms.DockStyle.Fill
        Me.lvwProperties.Location = New System.Drawing.Point(00)
        Me.lvwProperties.Name = "lvwProperties"
        Me.lvwProperties.Size = New System.Drawing.Size(292273)
        Me.lvwProperties.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(292273)
        Me.Controls.Add(Me.lvwProperties)
        Me.Name = "Form1"
        Me.Text = "ReflectionListProperties"
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents lvwProperties As System.Windows.Forms.ListView

End Class

           
       
Related examples in the same category
1. Reflection Information for Integer ClassReflection Information for Integer Class
2. Use Reflection to create Class instance and call methodUse Reflection to create Class instance and call method
3. Define Attributes and Use Reflection to get its valueDefine Attributes and Use Reflection to get its value
4. Get Method information and invoke Method using Reflection APIGet Method information and invoke Method using Reflection API
5. Get Method InformationGet Method Information
6. Get Class Member and Property Information from base and inherited ClassGet Class Member and Property Information from base and inherited Class
7. Reflection: display the member of Form ClassReflection: display the member of Form Class
w_w___w___.jav_a2___s___.___co__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.