Solved

listview just displaying four items

Posted on 2013-06-03
5
347 Views
Last Modified: 2013-06-04
Hi,

I have a listview which should be displaying all the records from the database.  But it keeps displaying only 4 records that too recently added. it ignores all the previous items.  Any idea how to resolve this?

HEre is the code for it.
  Try
         
            If d.ditems.Count > 0 Then


             
                Dim foo As String
                Dim foo1() As String
                Dim item As ListViewItem
                lvfoo.Items.Clear()
                'For Each foo In d.ditems
         
                    foo1 = foo.Split("|")
                    item = New ListViewItem(foo(0))
                    Me..Items.Add(item)
                    item.SubItems.Add(foo(1))
                    item.SubItems.Addfoo(2))

                    'item = Nothing
                Next
            End If
        Catch ex As Exception
            SystemException(ex.ToString)
        End Try

Open in new window

0
Comment
Question by:developer2012
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 39218122
Hi,

Can you check the value of d.ditems.Count? How do you populate the items in d.ditems.count?
0
 

Author Comment

by:developer2012
ID: 39218136
I am populating the values from database.
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39218204
the ode u posted is not compiled and also has a logic error in it.
i assume d.ditems contains the data from database?
did u debug the code and check how many records are they?
u can using linq, to add the records to the listview without iterating the items:
  Try
         
            If d.ditems.Count > 0 Then

                lvfoo.Items.Clear()
        Dim items As ListViewItem() = d.ditems.Select(Function(item) New ListViewItem(item.Split("|").ToArray))
        lvfoo.Items.AddRange(items)
            End If
        Catch ex As Exception
            SystemException(ex.ToString)
        End Try

Open in new window

0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 39218366
Can you show us the code on how you populate the d.ditems?
0
 

Author Comment

by:developer2012
ID: 39219077
Fixed.
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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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