0

我有一个包含很多东西的表单,包括文本框、图像、面板和数据库。问题是,当我开始运行它时,会显示窗口,但在显示窗口几秒钟后会显示内容。

我尝试在表单的显示事件中删除此重要代码。它有点用,但程序不能正常工作:

Private Sub Inventory_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
    Label1.Parent = PictureBox1
    Label2.Parent = PictureBox1
    OpenConnection()
    Dim da As SqlDataAdapter = New SqlDataAdapter("Select * from inventory order by [Item No] asc", conn)
    Dim ds As New DataSet
    da.Fill(ds, "inventory")
    DataGridView1.DataSource = ds.Tables("inventory")
    DataGridView1.ClearSelection()
    conn.Close()
    If DataGridView1.RowCount <> 0 Then
        PictureBox1.Visible = False
        Label1.Visible = False
        Label2.Visible = False
    End If
    TextBox2.Focus()
    MG.Visible = True
    btnClear.PerformClick()
    txtItemNo.ReadOnly = False
    txtItemNo.Text = DataGridView1.RowCount + 1
    txtItemNo.ReadOnly = True
    btnDelete.Enabled = False
    clearExpiryDate.Visible = False
End Sub

我该如何解决这个延迟?

4

0 回答 0