TableLayoutPanel设置滚动条值并不总是有效 [英] TableLayoutPanel set scroll bar value does not always work

查看:378
本文介绍了TableLayoutPanel设置滚动条值并不总是有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试同步两个TableLayoutPanel的HScrollBar,我发现在单击此面板中的一个控件导致面板重绘后,设置Horizo​​ntalScroll的值停止工作。  我也尝试增加LargeChange,
它没有效果。

I am trying to synchronize the HScrollBar of two TableLayoutPanel, I found that setting the Value of HorizontalScroll stops working after I clicked one of the controls inside this panel which caused the panel to redraw.   I also tried to increase LargeChange, it has no effect.

这是我使用的代码:

_tlp.Horizo​​ntalScroll.LargeChange = _tlpLocationHeaders.Horizo​​ntalScroll.Maximum;
$
_tlp.Horizo​​ntalScroll.Value = e.NewValue;

_tlp.PerformLayout();

_tlp.HorizontalScroll.LargeChange = _tlpLocationHeaders.HorizontalScroll.Maximum;
_tlp.HorizontalScroll.Value = e.NewValue;
_tlp.PerformLayout();

有谁知道如何一致地设置TLP的Horizo​​ntalScroll.Value?什么阻止它被设置?

Does anyone know how to consistently set TLP's HorizontalScroll.Value? What prevents it from being set?

谢谢。

FL

推荐答案

嗨PeterFL,

Hi PeterFL,

通常如果我们想以编程方式更改滚动位置,首先,我们需要将AutoScroll属性设置为True。然后使用Horizo​​ntalScroll.Value或VerticalScroll.Value设置滚动位置。发布内部控件的
的click事件处理程序会更好,这会导致面板重绘。我怀疑在这个事件处理程序中你需要重置TableLayoutPanel的原始属性然后刷新它。

Usually if we want to change the scroll position programmatically, firstly we need to set the AutoScroll property to True. Then use HorizontalScroll.Value or VerticalScroll.Value to set the scroll position. It's better to post the click event handler of the inner control which caused the panel to redraw. I suspect that in this event handler you need to reset the original properties for the TableLayoutPanel and then refresh it.

顺便说一下,
Windows窗体应用程序论坛
是最适合您的问题的地方。

By the way, Windows Forms Application forum is the most suitable place for your question.


这篇关于TableLayoutPanel设置滚动条值并不总是有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆