刷新Listview中的ListView项目 [英] Refreshing ListView Items in Listview

查看:107
本文介绍了刷新Listview中的ListView项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Sir



我已经编写了ListView的代码填充form_Shown事件中的项目,但是当我在新的项目中添加新项目和修改项目时弹出窗体数据库在msaccess以及onPpulateView过程中得到更新,但listView没有得到更新。我绑定了我为此编写的代码。下面是代码..

Sir pl帮我刷新listview。

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
       lstLocation.Items.Clear()

       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)
               items.Add(liItem)
           Next
           Me.lstLocation.Items.AddRange(items.ToArray)
           Me.lstLocation.Update()
       End If
   End Sub

推荐答案

当您从弹出窗口向数据库添加新项目时,您将不得不调用表单关闭后,再次 populateListView 方法。这将解决您的问题



通过改善您的问题发布打开弹出窗口的代码
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


这篇关于刷新Listview中的ListView项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆