Click here to Skip to main content
14,920,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir

I have written the code for the ListView Populating with the items in the form_Shown event but when I have add new item and modify item on a new popup form the database is got updated in msaccess as well as onPpulateView procedure but listView does not get update. I am binding the code that I have written for that..below is the code ..
Sir pl help me how we refresh the listview.
Private Sub populateListView(dtLoc As DataTable)
       Dim items As New List(Of ListViewItem)
       Dim liItem As ListViewItem = Nothing
       Me.lstLocation.LargeImageList = Me.imgLocations

       If (Not (dtLoc Is Nothing)) Then
           For i As Integer = 0 To dtLoc.Rows.Count - 1
               liItem = New ListViewItem()
               liItem.Text = dtLoc.Rows(i).Item("Controller_Tag").ToString
               liItem.ToolTipText = dtLoc.Rows(i).Item("Controller_Tag").ToString
               liItem.ImageIndex = CInt(dtLoc.Rows(i).Item("Image_Index").ToString)
       End If
   End Sub

1 solution

As you are adding new item to the database from the popup window, you will have to call the populateListView method again after the form is closed. This will solve your problem

Post your code for opening the popup window by Improving your question
Omparkash 20-Sep-13 5:53am
I have called this method on Form_Closed event of popup window but not get refreshed..
Madhu Nair 20-Sep-13 6:16am
if you are displaying the popup window using the showdialog method then call populateListView after showdialog method is called. it will automatically get executed after the popup window is closed.
Omparkash 20-Sep-13 7:11am
Thanks sir I got Solution thanks very much
Madhu Nair 20-Sep-13 7:28am
Mark the Post as answered which will help others also

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900