【问题标题】:Display Images from a File into Pictureboxes将文件中的图像显示到图片框中
【发布时间】:2017-06-01 08:12:42
【问题描述】:

我有一个名为

的文件夹

App.Path & "\Images"

在其中我有 5 张图片,在我的 Form 中还有 5 张 Pictureboxes。现在我的问题是,如何一次将它们全部显示为PictureBoxImage?到目前为止,这是我的代码

Picture1.Picture = LoadPicture("Path")

这是我到目前为止所做的

 Dim c         As Control
    Dim ImageLink As String

    With vs1

        For Each c In Form1
            For i = 1 To .Rows - 1

                If Len(ImageLink) > 0 Then ImageLink = ImageLink


                Debug.Print c.Picture
                Debug.Print .TextMatrix(i, .ColIndex("Image"))
                MsgBox .TextMatrix(i, .ColIndex("Image"))
                c.Picture = LoadPicture("C:\Users\paul\Desktop\Gondola Monitoring System\Image\" & .TextMatrix(i, .ColIndex("Image")))

            Next
        Next
    End With
    Form1.Show

我尝试在 flexgrid 中写入文件名并在每个控件中调用它。

TYSM 寻求帮助

【问题讨论】:

    标签: image vb6 picturebox


    【解决方案1】:
    Picture1.Picture = LoadPicture(App.Path & "\Images\file1.jpg")
    Picture2.Picture = LoadPicture(App.Path & "\Images\file2.jpg")
    Picture3.Picture = LoadPicture(App.Path & "\Images\file3.jpg")
    Picture4.Picture = LoadPicture(App.Path & "\Images\file4.jpg")
    Picture5.Picture = LoadPicture(App.Path & "\Images\file5.jpg")
    

    如果这不能满足您的需求,请提供有关您的要求的更多详细信息。

    编辑

    您的代码无法正常工作。您正在遍历所有控件,其中包括任何按钮、标签等,除了图片控件,并且对于每个控件,您正在遍历网格的所有行。一种更好的方法是将图片控件定义为一个数组(从 1 开始索引以匹配您的网格 for 循环),然后使用 for 索引,以便网格行和图片索引匹配。像这样的:

    With vs1
        For i = 1 To .Rows - 1
            Picture1(i).Picture = LoadPicture("C:\Users\paul\Desktop\Gondola Monitoring System\Image\" & .TextMatrix(i, .ColIndex("Image")))
        Next
    End With
    

    【讨论】:

      猜你喜欢
      • 2014-06-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      • 2014-12-17
      • 1970-01-01
      相关资源
      最近更新 更多