惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

博客园 - gucs

《应用框架的设计与实现——.NET平台》书评 《WCF Unleashed》的 AzRoles 演示代码 Tech Ed 2009,胡思乱想 Mac 双系统的时间设置问题 使用 gVim 遇到的第一个问题 Google notebook for Firefox 3.5 Fiddler & localhost Powerdesigner 12.5 对 SQL Server 2005 做反向工程时发生错误 VisualSVN Server 的 Apache 配置 ExplorerXP 在 Vista 下的设置 ReSharper 2.0.4 安装时的 1722 错误 禁用 Nero ShowTime 快捷键 使用 ModalPopupExtender 和 UpdatePanel 应注意的问题 NHibernate 和 ODP.NET 手动注册 DevExpress 8.2.3 控件到 Visual Studio 工具箱 PPStream caused an Access Violation (0xc0000005) in module VSFilter.dll at 001b:07610441. 隐藏 Windows Vista 的 Explorer 菜单栏 ReadOnly Controls do not post back properly 使用 ExtJs Extender Controls 遇到的第一个错误
关于 TableLayoutPanel 的 Scroll bar
gucs · 2009-02-25 · via 博客园 - gucs

为简化多个控件的布局,我在项目中使用了 TableLayoutPanel,并且设置了 AutoScroll = true,以实现滚动条功能。QA 在测试过程中发现两个问题:

  1. TableLayoutPanel 内容过多时,达到某一个高度后,其下的所有行都不能正确显示。
  2. 使用鼠标移动滚动条,再切换到另一个窗体或程序,重新激活该窗体后滚动条又恢复到最初状态,页面保持在最上方。

通过了多次 Google,基本搞清楚了是什么原因:

  1. 这是 TableLayoutPanel 的一个 bug,经过测试,FlowLayoutPanel 也存在同样的问题。一个老外也遇到了同样的问题,并提供了解决方法

    While I didn't figure out why FlowLayoutPanel doesn't draw the items below a certain point, I found a workaround.
    Attach an event handler to Scroll, where you perform FlowLayoutPanel.PerformLayout() and it will draw the controls when you get to them.

  2. 原以为也是 Microsoft 的 Bug,可是看了官方的回复,我也只有 workaround 了。
    Due to the fact that it is the previously shipped behavior of Form to always scroll the active control into view when the Form is activated, we will not be able to change this. We can consider a property to disable this functionality, but this feature will not make the Whidbey release. We will consider it for a future release.

下面是解决该上面问题的代码,供参考:

private void WFPanel_Load(object sender, EventArgs e)
{
    flpCharts.MouseWheel
+= flpCharts_MouseWheel;
}
private void flpCharts_MouseWheel(object sender, MouseEventArgs e)
{
    flpCharts.Focus();
}
private void flpCharts_Scroll(object
sender, ScrollEventArgs e)
{
    flpCharts.PerformLayout();
    flpCharts.Focus();
}

其中,Scroll 事件的第一和第二行代码,分别是为了解决前面提到的两个问题。而 MouseWheel 事件,则是为了处理第二个问题使用鼠标滚轮的场合。因为 MouseWheel 事件在 Designer 中找不到,只有在 Load 事件中手动注册了。