Solved

vb.net - add item to listview

Posted on 2013-01-21
1
513 Views
Last Modified: 2013-01-21
hello,
I have this little code here to load data into a listview from a text file..
how can I change that up so it loads from a string called "strData"
that has the records line by line

            Using sr As New System.IO.StreamReader(strData, True)
                While Not sr.EndOfStream
                    strLine = sr.ReadLine
                    If strLine <> "" And Not strLine.StartsWith("#") Then
                        tabLine = strLine.Split(strSept)
                        lItem = lstView.Items.Add(tabLine(0))
                        For j As Integer = 1 To tabLine.GetUpperBound(0)
                            lItem.SubItems.Add(tabLine(j))
                        Next j
                        For j As Integer = tabLine.Count To 5
                            lItem.SubItems.Add(tabReplace(j))
                        Next j

                        lItem.SubItems(3).Text = "0"
                        lItem.SubItems(4).Text = "0"
                    End If
                End While
            End Using

Open in new window

0
Comment
Question by:XK8ER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 38803866
Just use Split() on strData with a For loop:
        For Each strLine In strData.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
            If strLine <> "" And Not strLine.StartsWith("#") Then
                tabLine = strLine.Split(strSept)
                lItem = lstView.Items.Add(tabLine(0))
                For j As Integer = 1 To tabLine.GetUpperBound(0)
                    lItem.SubItems.Add(tabLine(j))
                Next j
                For j As Integer = tabLine.Count To 5
                    lItem.SubItems.Add(tabReplace(j))
                Next j

                lItem.SubItems(3).Text = "0"
                lItem.SubItems(4).Text = "0"
            End If
        Next

Open in new window

0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question