如何在VB.Net中预加载表单?

时间:2013-09-11 01:03:31

标签: vb.net

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

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

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

如何修复此延迟?

0 个答案:

没有答案