Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何在运行应用程序时使列表不断更新。VB_Vb.net_Winforms - Fatal编程技术网

Vb.net 如何在运行应用程序时使列表不断更新。VB

Vb.net 如何在运行应用程序时使列表不断更新。VB,vb.net,winforms,Vb.net,Winforms,我如何让我的列表在应用程序运行时一直更新,而不是仅在启动应用程序时更新 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load On Error Resume Next Dim username As String username = SystemInformation.

我如何让我的列表在应用程序运行时一直更新,而不是仅在启动应用程序时更新

Private Sub Form1_Load(ByVal sender As System.Object,
                          ByVal e As System.EventArgs) Handles MyBase.Load
    On Error Resume Next
    Dim username As String
    username = SystemInformation.UserName
    Dim filesInFolder As String
    filesInFolder= "C:\Users\" + username + "\AppData\Roaming\pictures\pics"

    Dim di As New IO.DirectoryInfo(filesInFolder)
    Dim aryFi As IO.FileInfo() = di.GetFiles("*.jpg")
    Dim fi As IO.FileInfo

        For Each fi In aryFi
            list.Items.Add(fi.Name)
        Next
End Sub
你可以用定时器

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim timer as New windows.forms.timer
    AddHandler timer.Tick, Addressof MyTimerHandlersSub        
    timer.start()

    End Sub

    Private Sub MyTimerHandlersSub(ByVal sender As System.Object, ByVal e As
System.EventArgs)
       'Update Your List Here.
    End Sub 
你可以用定时器

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim timer as New windows.forms.timer
    AddHandler timer.Tick, Addressof MyTimerHandlersSub        
    timer.start()

    End Sub

    Private Sub MyTimerHandlersSub(ByVal sender As System.Object, ByVal e As
System.EventArgs)
       'Update Your List Here.
    End Sub 

我想你是在找那个

侦听文件系统更改通知,并在目录或目录中的文件更改时引发事件


我想你是在找那个

侦听文件系统更改通知,并在目录或目录中的文件更改时引发事件


你有代码要显示吗?你自己试过什么吗?我们需要比“你的名单”更多的细节。数据来自哪里?你有没有从数据库加载它?是xml吗?这是小精灵吗?你需要提供更多的细节,包括展示你目前拥有的以及解释期望的结果。我们不知道你的应用程序是什么,列表当前是如何更新的等等。很抱歉,现在添加了一些代码。我个人会查看这个类。你有代码要显示吗?你自己试过什么吗?我们需要比“你的名单”更多的细节。数据来自哪里?你有没有从数据库加载它?是xml吗?这是小精灵吗?你需要提供更多的细节,包括展示你目前拥有的以及解释期望的结果。我们不知道你的应用程序是什么,列表当前是如何更新的等等。很抱歉,我现在添加了一些代码。我个人会看看这个类。