如何使滚动条出现在一个可调整大小的面板时,所包含的控制是太大了吧? [英] How to make scrollbars appear in a resizable panel when the contained control is too big for it?

查看:197
本文介绍了如何使滚动条出现在一个可调整大小的面板时,所包含的控制是太大了吧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Windows窗体应用程序(.NET 2.0,VS 2005)。我有一个主要包含一个面板,动态的形式调整形式:

I am developing a Windows Forms application (.NET 2.0, VS 2005). I have a form that essentially contains a panel that is dynamically resized with the form :

this.panel1.Dock=DockStyle.Fill;

此面板直接作为容器。在运行时,一个自定义的控制将被添加:

This panel is simply used as a container. At runtime, a custom control will be added :

UserControl uc=new UserControl();
panel1.Controls.Add(uc);
uc.Dock=DockStyle.Fill;

由于这种自定义的控制有一个最小尺寸的要求,我想滚动条出现在含面板上,如果它变得太小,无法显示整个控制:

As this custom control has a minimum size requirement, I want scroll bars to appear on the containing panel if it gets too small to show the entire control :

this.panel1.AutoScroll=true;

这是行不通的。我试图调整使用Anchor属性,而不是Dock属性面板,但没有成功。

This does not work. I have tried to resize the panel using the Anchor property rather than the Dock property, to no avail.

推荐答案

不要插接您的用户控制。使用锚属性。 (主播四面)。 设置你的用户控件的属性的minimumSize 设置面板的AutoScrollMinSize属性还

Don't Dock your User control. Use the Anchor property instead. (Anchor to all four sides). Set you User control's MinimumSize property Set the panel's AutoScrollMinSize property

除非你将其AutoScrollMinSize属性还小组的滚动条将不会出现。设置用户控件的Dock来填充似乎隐藏面板的滚动条。

The Panel's scrollbars won't appear unless you set its AutoScrollMinSize property. Setting the user control's Dock to Fill seems to hide the panel's scrollbars.

这篇关于如何使滚动条出现在一个可调整大小的面板时,所包含的控制是太大了吧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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