C# 如何在tabcontrol/tabpages中添加垂直滚动条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18782369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to add vertical scroll bars in tabcontrol/tabpages
提问by Kratos
I am designing an application in which i am using tab-control, and in one of the tab-page the information i want to display in bigger than the form size, the information is displayed in various text-boxes. i tried by adding following lines in designer code but it is still not working.
我正在设计一个应用程序,我在其中使用选项卡控件,并且在其中一个选项卡页中,我希望显示的信息大于表单大小,信息显示在各种文本框中。我尝试在设计器代码中添加以下行,但它仍然无法正常工作。
this.AutoScroll = true;
this.AutoScrollMargin = new System.Drawing.Size(20, 20);
this.AutoScrollMinSize = new System.Drawing.Size(this.Width, this.Height);
any help would be appreciated.
任何帮助,将不胜感激。
采纳答案by King King
You have to set the AutoScroll
on the TabPage
, not the Form
, you can do this at design time by selecting your tabpage first, then set the AutoScroll to true in the Properties window, or you can do by code like this:
您必须设置AutoScroll
on 而TabPage
不是Form
,您可以在设计时通过首先选择您的标签页来执行此操作,然后在“属性”窗口中将 AutoScroll 设置为 true,或者您可以通过如下代码执行此操作:
tabPage1.AutoScroll = true;
//do the same for other tabPages
回答by AmirHossein Rezaei
Notice that "this" refer to whole class (your form).
请注意,“this”是指整个班级(您的表格)。
Increase the value like this:
像这样增加值:
tab.AutoScrollMinSize = new System.Drawing.Size(1000,1000);
Or you can add panel1
to your tab, then dock it into the tab:
或者您可以添加panel1
到您的选项卡,然后将其停靠在选项卡中:
panel1.dock = dockingSyle.Fill;
Now you can make panel1
scrollable.
现在你可以使panel1
滚动。