Vya*_*Dev 10 c# tablelayoutpanel winforms
我使用TableLayoutPanel进行出勤标记.我在此TableLayoutPanel中添加了控件(Panel和Label)并为它们创建了事件.在某些情况下,我已经清除了所有控件,并继续将相同的控件绑定在TableLayoutPanel的不同位置.在重新绑定控件时,TableLayoutPanel会在初始化时闪烁并且速度太慢.
Ian*_*Ian 19
暂停布局,直到您添加了所有控件.
TableLayoutPanel panel = new TabelLayoutPanel();
panel.SuspendLayout();
// add controls
panel.ResumeLayout();
Run Code Online (Sandbox Code Playgroud)
另请参阅使用双缓冲.您必须创建TableLayoutPanel的子类.在这里查看示例.
这对我很有用.删除由于Windows窗体中的TableLayoutPanel和Panel导致的闪烁
这里是什么链接(复制逐字)
完全删除由于Windows窗体中的TableLayoutPanel和Panel导致的闪烁,如下所示:= - 1.设置Form = true的双缓冲属性.2.在form.cs中粘贴以下2个函数
Run Code Online (Sandbox Code Playgroud)#region .. Double Buffered function .. public static void SetDoubleBuffered(System.Windows.Forms.Control c) { if (System.Windows.Forms.SystemInformation.TerminalServerSession) return; System.Reflection.PropertyInfo aProp = typeof(System.Windows.Forms.Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); aProp.SetValue(c, true, null); } #endregion #region .. code for Flucuring .. protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; return cp; } } #endregion
- 调用
SetDoubleBuffered(“TableLaoutPannel_controlName”)每个TableLayoutPannel,Pannel,Splitcontainer,Datagridview和所有的容器控件.感谢RhishikeshLathe发表于16-Feb-14 20:11 pm
小智 5
VB.net:
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H2000000
Return cp
End Get
End Property
Run Code Online (Sandbox Code Playgroud)
C#:
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle = cp.ExStyle | 0x2000000;
return cp;
}
}
Run Code Online (Sandbox Code Playgroud)
在 VB 中,将它添加到受影响类的底部,我向您保证它会起作用。
在 C# 中,将属性与其他属性一起添加到类的顶部。
它基本上等待 Winform 的完整渲染,并消除正在绘制到屏幕上的窗体的闪烁。如果你还没有测试过,请不要无视。我在 winform 延迟方面遇到了一个大问题,这解决了它。