如何在使用 C# 上课时调整所有内容的大小? [关闭]

问题描述 投票:0回答:0

每次创建新标签时,内容都会出现,但当整个页面调整大小时,内容不会调整大小。它在没有类的情况下工作正常,但每当我尝试将它与类集成时它不会调整大小。如何让内容随页面调整大小?

这是我的 Windows 窗体应用程序代码,

Form1.cs:

    private void CreateNewTab()
    {
        recipeTab tab = new recipeTab();
        TabPage newTab = new TabPage();
        tab.tabSplit = new SplitContainer();
        tab.image = new PictureBox();
        tab.title = new TextBox();
        tab.save = new Button();
        tab.rightSplit = new SplitContainer();
        tab.ingredientsText = new RichTextBox();
        tab.label3 = new Label();
        tab.instructionsText = new RichTextBox();
        tab.label4 = new Label();
        newTab.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)tab.tabSplit).BeginInit();
        tab.tabSplit.Panel1.SuspendLayout();
        tab.tabSplit.Panel2.SuspendLayout();
        tab.tabSplit.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)tab.image).BeginInit();
        ((System.ComponentModel.ISupportInitialize)tab.rightSplit).BeginInit();
        tab.rightSplit.Panel1.SuspendLayout();
        tab.rightSplit.Panel2.SuspendLayout();
        tab.rightSplit.SuspendLayout();

        // I add all the properties below here            

        tabControl1.add(newTab);
    }

recipeTab.cs

    internal class recipeTab
    {
        public TabPage newTab { get; set; }
        public SplitContainer tabSplit { get; set; }
        public PictureBox image { get; set; }
        public TextBox title { get; set; }
        public Button save { get; set; }
        public SplitContainer rightSplit { get; set; }
        public RichTextBox ingredientsText { get; set; }
        public Label label3 { get; set; }
        public RichTextBox instructionsText { get; set; }
        public Label label4 { get; set; }
    }

我是 c# 和 Windows 窗体的新手,所以请详细解释需要发生什么。

c# windows class windows-forms-designer tabcontrol
© www.soinside.com 2019 - 2024. All rights reserved.