VB在初始屏幕上加载照片

时间:2019-12-02 12:50:32

标签: vb.net visual-studio visual-studio-2010 visual-studio-2012 basic

我正在尝试将所有照片加载到系统上的按钮中。登录后我设法使其加载,但是登录后图像需要花费一些时间才能加载。因此,我想使其在启动屏幕后加载。

Private Sub picture()
    Dim filePath As String

    filePath = "C:\Users\ress\source\repos\restaurant 2019\text\food_image.txt"
    Dim lines() As String = System.IO.File.ReadAllLines(filePath)

    fAdmin.btnFood0.Image = Image.FromFile(lines(0))
    fMain.btnFood0.Image = Image.FromFile(lines(0))
    fAdmin.btnFood1.Image = Image.FromFile(lines(1))
    fMain.btnFood1.Image = Image.FromFile(lines(1))
    fAdmin.btnFood2.Image = Image.FromFile(lines(2))
    fMain.btnFood2.Image = Image.FromFile(lines(2))
    fAdmin.btnFood3.Image = Image.FromFile(lines(3))
    fMain.btnFood3.Image = Image.FromFile(lines(3))
    fAdmin.btnFood4.Image = Image.FromFile(lines(4))
    fMain.btnFood4.Image = Image.FromFile(lines(4))
    fAdmin.BtnFood5.Image = Image.FromFile(lines(5))
    fMain.BtnFood5.Image = Image.FromFile(lines(5))
End Sub

1 个答案:

答案 0 :(得分:0)

我建议您可以使用表单显示事件来加载照片。

代码:

Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        picture()

    End Sub