在VB.net中加载时如何防止控件闪烁?

我目前的 Windows 应用程序存在问题。这是我的问题的视频。

Flickering Problem

如您所见,每次我单击某些按钮并加载控件(选项卡控件和面板)时,它们都会闪烁,看起来很烦人。我怎样才能摆脱这个?我已经尝试将 DoubleBuffer 设置为 true 但仍然无法正常工作。有什么帮助吗?

我还在加载事件中执行了暂停布局()和恢复布局(),但仍然无法正常工作。或者可能是因为我编码错误。这是我的代码:

Private Sub frmAdminPanel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        lblUser.Text = currentUser
        Me.pnlOverview.SuspendLayout()
        Me.tabPayment.Visible = False
        Me.tabClientReporting.Visible = False
        Me.btnNewEntry.Visible = False
        Me.btnPayment.Visible = False
        setOverview()
        Me.pnlOverview.Visible = True
        Me.pnlOverview.ResumeLayout()
    End Sub
stack overflow How to prevent controls from flickering when loading in VB.net?
原文答案

答案:

作者头像

If there is any code in Load event of the form that manipulates the UI then you should try using SuspendLayout() and ResumeLayout() to prevent flickering.

作者头像

Instead of using SuspendLayout and ResumeLayout, try using BeginUpdate and EndUpdate.