当窗口或容器的大小如何解决滚动条? [英] How to fix scrollbars when the window or container is resized?

查看:337
本文介绍了当窗口或容器的大小如何解决滚动条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前在我的应用我使用HScrollBar控件控件和VScrollBar在一个大的图像平移左右。所显示的图像的一部分是基于滚动条的Value属性。然而,调整大小的SplitContainer或调整窗体窗口时滚动条的值不会自动更新,这可能会导致一些关闭屏幕。

Currently in my application I am using the HScrollBar and VScrollBar for panning around in a large image. The part of the image that is shown is based on the scrollbar's Value property. However, when resizing the SplitContainer or resizing the form window the scrollbar's Value does not automatically update and it may render something off-screen.

在这一点上,我注意到,如果你点击滚动条的箭头,它神奇地修复了滚动条。我在想,如果有任何的方式来模拟点击滚动条要做到这一点在Form_Resize和SplitContainer_Resize事件处理程序,但我无法找到任何东西。

At this point I noticed that if you clicked the scrollbar's arrow it magically fixes the scrollbar. I was wondering if there was any way to simulate clicking the scrollbar to do this in the Form_Resize and SplitContainer_Resize event handlers but I couldn't find anything.

无需手动调整滚动条的所有调整事件的价值是缓慢的,丑陋的,而且不能很好地工作。我真的希望,当调整窗口大小就像当你点击它的箭头它,但我不知道怎么样。

Having to manually adjust the scrollbar's value in all resizing events is slow, ugly, and doesn't work well. I'd really like for the scrollbar to just automatically fix itself when the window resizes like it does when you click its arrow but I'm not sure how.

推荐答案

尝试调用在窗体的resize事件处理函数滚动条的的Invalidate()方法:结果
http://msdn.microsoft.com/en-us/library/system。 windows.forms.control.invalidate.aspx

Try calling the scrollbar's Invalidate() method in the form's resize event handler:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.invalidate.aspx

这应该会导致它正确地重新绘制表格的大小后。

That should cause it to redraw correctly after the form is resized.

这篇关于当窗口或容器的大小如何解决滚动条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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