tablelayoutpanel刷新闪烁问题...

ffsquare 2009-02-28 06:17:45
使用tablelayoutpanel当容器,里面放了一堆控件,每次一次性要刷新40多个LABEL,这时界面闪烁的非常厉害,我更改LABEL的TEXT前时候了使用了一个什么 s什么什么layout方法,在全部刷新完后再使用resumelayout方法,好象不太好用,请问还有什么方法能是他刷新时不会闪烁?????
...全文
1167 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
william_ys 2011-04-26
  • 打赏
  • 举报
回复
楼上正解。
harry960 2010-05-02
  • 打赏
  • 举报
回复
我也遇到了闪烁的问题,用一下方式解决的:
private void btnAction_Click(object sender, EventArgs e)
{
tableLayoutPanel1.SuspendLayout();
tableLayoutPanel1.Controls.Clear();
//这里动态的添加了一些控件,以前例如:
//tableLayoutPanel1.Controls.Add(*,*,*);
tableLayoutPanel1.ResumeLayout();
}
以前前后没有加SuspendLayout和ResumeLayout时,执行这个单击事件就会明显的闪烁,加了之后就不会闪烁了。


如果你的控件是在设计时就已经放置好的,那么可以把.Designer.cs中对应的添加控件代码放到.cs文件中去。
cppfaq 2009-03-05
  • 打赏
  • 举报
回复
自己使用GDI+来进行绘图。别无良方。
ffsquare 2009-03-01
  • 打赏
  • 举报
回复
那有没有别的方法代替tablelayoutpanel??????
我主要用tablelayoutpanel排列控件,好让控件整齐显示.
如果不用那个的话控件的排列就是个问题,刷新部分用datagrid显示的话好象还不大好看.
还有什么办法解决这个问题吗????
cppfaq 2009-02-28
  • 打赏
  • 举报
回复
It wouldn't surprise me that you get flicker with this number of controls. either:

1. Reduce the number of controls , this is more than likely not an option...

2. perform your own 'drawing' onto the form (or usercontrol) itself (and use doublebuffering to improve the graphical smothness).

You may be able to use SuspendLayout() and ResumeLayout() (not sure if it'll improve things or not).

3. Set it's visibility to false before you update if, then set it back after you finish(still not sure whether it will help)

What is happening is that when you update each label, it is clearing itself by 'filling' in the background color, then displaying the value you want. The more controls you have, the more noticable this effect.
cppfaq 2009-02-28
  • 打赏
  • 举报
回复
tablelayoutpanel的子控件数量过多的时候会有严重的性能问题,内部会发生很多次layout计算。
jeremychin 2009-02-28
  • 打赏
  • 举报
回复
最好不要用如此多的控件 如果只是显示文本可以用多行文本

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧