Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

How to show text files records in a listview

 by Satyapriya Nayak on Jan 10, 2012

In this blog we will know how to show text files records in a listview.
Download Files: listview1.rar
Comments: 0 Views: 746 Printable Version 

In this blog we will know how to show text files records in a listview.

 

 

Imports System.IO

Public Class Form1

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim Id As String

        Dim Name As String

        Dim Gender As String

        Dim Address As String

 

        Try

 

            Dim sr As StreamReader

            Dim fs As FileStream

            fs = New FileStream(("C:\temp\a.txt"), FileMode.OpenOrCreate)

            sr = New StreamReader(fs)

            Dim itm As Object

            itm = sr.ReadLine

            While Not itm = Nothing

                Dim split As String() = itm.Split(New [Char]() {" "})

                Id = split(0)

                Name = split(1)

                Gender = split(2)

                Address = split(3)

                ListView1.Items.Add(Id)

                ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(Name)

                ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(Gender)

                ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(Address)

                itm = sr.ReadLine

            End While

 

            sr.Close()

            fs.Close()

            ListView1.Columns.Add("Id", 70, HorizontalAlignment.Center)

            ListView1.Columns.Add("Name", 70, HorizontalAlignment.Center)

            ListView1.Columns.Add("Gender", 70, HorizontalAlignment.Center)

            ListView1.Columns.Add("Address", 70, HorizontalAlignment.Center)

            ListView1.View = View.Details

            ListView1.GridLines = True

            ListView1.BackColor = Color.Aqua

            ListView1.ForeColor = Color.Blue

        Catch ex As System.Exception

            System.Windows.Forms.MessageBox.Show(ex.Message, "Load Tool Data Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try

    End Sub

End Class

 

 

 

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
Nevron Gauge for SharePoint
Become a Sponsor

 Blogger's Profile
Age: Not Available
Location:
Title: Student
Joined: Aug 02, 2010
Education: Bachelors Degree
 More Blogs from this Blogger
No record available
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.