Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WinForms TableLayout赢得';缩小规模_C#_.net_Winforms_Mono_Tablelayoutpanel - Fatal编程技术网

C# WinForms TableLayout赢得';缩小规模

C# WinForms TableLayout赢得';缩小规模,c#,.net,winforms,mono,tablelayoutpanel,C#,.net,Winforms,Mono,Tablelayoutpanel,直截了当地问 资料: 我制作了这个自定义用户控件(称为ExpansivePanel),其中包含以下内容: - TableLayoutPanel (Call it ProblemTable) - Label (C0, R0) - Button (C1, R0) - Panel (C0, R1, CSpan2) 单击按钮时,面板展开/折叠以显示内容 问题: 问题是,当我将其作为控件添加到另一个容器中并尝试调整其大小时,扩展面板下的操作都是正确的,但从问题表开始,只有当新

直截了当地问


资料: 我制作了这个自定义用户控件(称为ExpansivePanel),其中包含以下内容:

- TableLayoutPanel (Call it ProblemTable)
    - Label (C0, R0)
    - Button (C1, R0)
    - Panel (C0, R1, CSpan2)
单击按钮时,面板展开/折叠以显示内容


问题: 问题是,当我将其作为控件添加到另一个容器中并尝试调整其大小时,扩展面板下的操作都是正确的,但从问题表开始,只有当新大小大于当前大小时,它才会调整大小,当然,它的内容也不会调整大小,除非其大小在增长。 这在Linux上发生。在Windows上,只有当用户设置的大小太小时才会发生这种情况


我已经尝试过的事情:
  • 在ProblemTable上设置Anchor而不是Dock(+将大小设置为ExpansivePanel本身,这在使用Anchors时是必需的),实际上不会改变任何东西
  • 正在删除ProblemTable上的Dock(Fill)属性,这会使表的大小变小(并且已修复!),但它的内容仍然很大并且位于它下面
  • 在ExpansivePanel上将Autosize设置为true,这会强制其大小为0,即使其内部有容器和控件
  • 在ProblemTable上将Autosize设置为true,这根本不会影响任何内容
  • 将ExpansivePanel和ProblemTable上的AutosizeMode设置为不同的值不会改变任何内容。(因为这里不能自动调整大小!)
  • 。。。还有一些我不记得的事情,因为我已经两天都在想这个问题了

详细资料: 我正在使用Ubuntu 16.04(MonoDevelop+Mono/.NET4.0)和Windows10(MonoDevelopUnity+Mono/.NET4.0)来构建和运行这个东西。这些都发生在Linux上,但在Windows上似乎没有问题,除非用户给出的大小太小,我认为这可能是自然的!是吗

以下是ExpansivePanel的构建方法(包含一些调试代码!):

下面是ExpansivePanel的父级的构建方法,它包含一个TableLayoutPanel容器,并将3个ExpansivePanel(Pnl_名称等)添加到它的表中。(构建不完整-包含一些调试代码!):


截图:
  • 初始状态。(i.stack.imgur.com/uOhWC.png)还没有发生任何事情。只是构建方法

  • 表格的内容隐藏在它下面。其大小不变的是ProblemTable(ExpansivePanel中的aka.Cnt_MainTable)

  • 表格会调整大小,其内容也会调整大小以适应表格大小。这里没有问题

  • 第二次裁员。(i.stack.imgur.com/m47uH.png)自上次增长以来,表不会调整大小,但它的父表会调整大小,使表隐藏在其父表之下


这与Mono有什么关系?标记已删除。正如我所提到的,我在Linux和Windows上都使用Mono编译了它。对不起,没有看到。祝Mono上的WInForms好运。这与Mono有什么关系?标记已删除。正如我所提到的,我在Linux和Windows上都使用Mono编译了它。对不起,没有看到。祝Mono上的WInForms好运。
    private void Build ()
    {
        #region Initialization
        this.Cnt_MainTable = new TableLayoutPanel (); // This is the ProblemTable
        this.Lbl_PanelName = new Label ();
        this.Pnl_Content = new Panel ();
        this.Btn_Expanse = new Button ();
        this.Cnt_MainTable.SuspendLayout ();
        this.SuspendLayout ();
        #endregion
        #region Cnt_MainTable
        this.Cnt_MainTable.Dock = DockStyle.Fill;
        this.Cnt_MainTable.Margin = new Padding(0);
        this.Cnt_MainTable.TabIndex = 1;
        this.Cnt_MainTable.ColumnCount = 3;
        this.Cnt_MainTable.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100F));
        this.Cnt_MainTable.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
        this.Cnt_MainTable.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
        this.Cnt_MainTable.RowCount = 2;
        this.Cnt_MainTable.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        this.Cnt_MainTable.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        this.Cnt_MainTable.Controls.Add (this.Lbl_PanelName, 0, 0);
        this.Cnt_MainTable.Controls.Add (this.Btn_Expanse, 2, 0);
        this.Cnt_MainTable.Controls.Add (this.Pnl_Content, 0, 1);
        this.Cnt_MainTable.Resize += (object sender, EventArgs e) =>
        {
            if (DebugPanel)
            {
                ConsoleLogger.Log ("Content Size = " + Pnl_Content.Size);
                ConsoleLogger.Log ("Label Size = " + Lbl_PanelName.Size);
                ConsoleLogger.Log ("Button Size = " + Btn_Expanse.Size);
            }
        };
        #endregion
        #region Lbl_PanelName
        this.Cnt_MainTable.SetColumnSpan (this.Lbl_PanelName, 2);
        this.Lbl_PanelName.Dock = DockStyle.Fill;
        this.Lbl_PanelName.Margin = new Padding (0);
        this.Lbl_PanelName.TabIndex = 1;
        this.Lbl_PanelName.TextAlign = ContentAlignment.MiddleCenter;
        #endregion
        #region Pnl_Content
        //this.Pnl_Content.AutoSize = true;
        //this.Pnl_Content.AutoSizeMode = AutoSizeMode.GrowAndShrink;
        this.Cnt_MainTable.SetColumnSpan (this.Pnl_Content, 3);
        this.Pnl_Content.Dock = DockStyle.Fill;
        this.Pnl_Content.Margin = new Padding (0);
        this.Pnl_Content.TabIndex = 2;
        #endregion
        #region Btn_Expanse
        this.Btn_Expanse.Dock = DockStyle.Fill;
        this.Btn_Expanse.BackColor = Color.Transparent;
        this.Btn_Expanse.BackgroundImage = ResourceManager.Btn_Hide;
        this.Btn_Expanse.BackgroundImageLayout = ImageLayout.Zoom;
        this.Btn_Expanse.FlatStyle = FlatStyle.Flat;
        this.Btn_Expanse.FlatAppearance.BorderSize = 0;
        this.Btn_Expanse.Margin = new Padding (0);
        this.Btn_Expanse.Size = new Size (24, 24);
        this.Btn_Expanse.TabIndex = 3;
        this.Btn_Expanse.UseVisualStyleBackColor = false;
        this.Btn_Expanse.Click += (object sender, EventArgs e) =>
        {
            IsExpanded = !IsExpanded;
        };
        #endregion
        #region This
        base.Controls.Add (this.Cnt_MainTable);
        this.Cnt_MainTable.ResumeLayout (false);
        this.ResumeLayout (false);
        #endregion
    }
private void Build ()
    {
        #region Initialization
        TableLayoutPanel Cnt_Main = new TableLayoutPanel ();
        TableLayoutPanel Cnt_CharID = new TableLayoutPanel ();
        ExpansivePanel Pnl_Names = new ExpansivePanel ();
        ExpansivePanel Pnl_Summaries = new ExpansivePanel ();
        ExpansivePanel Pnl_Attributes = new ExpansivePanel ();
        TableLayoutPanel Tbl_Names = new TableLayoutPanel ();
        TableLayoutPanel Tbl_Summaries = new TableLayoutPanel ();
        TableLayoutPanel Tbl_Attributes = new TableLayoutPanel ();
        this.Lbl_CharID = new Label ();
        this.Cmb_Names_Class = new ComboBox ();
        this.Dtp_Names_Begin = new DateTimePicker ();
        this.Dtp_Names_End = new DateTimePicker ();
        this.Lst_Attributes = new ListBox ();
        this.Lst_Names = new ListBox ();
        this.Lst_Summaries = new ListBox ();
        this.Txt_CharID = new TextBox ();
        this.Txt_Names = new TextBox ();
        this.Btn_Names_Add = new Button ();
        this.Btn_Names_Remove = new Button ();
        this.SuspendLayout ();
        #endregion
        #region Cnt_Main
        Cnt_Main.Dock = DockStyle.Fill;
        Cnt_Main.ColumnCount = 1;
        Cnt_Main.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100f));
        Cnt_Main.RowCount = 5;
        Cnt_Main.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Cnt_Main.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Cnt_Main.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Cnt_Main.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Cnt_Main.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Cnt_Main.Controls.Add (Cnt_CharID, 0, 0);
        Cnt_Main.Controls.Add (Pnl_Names, 0, 1);
        Cnt_Main.Controls.Add (Pnl_Summaries, 0, 2);
        Cnt_Main.Controls.Add (Pnl_Attributes, 0, 3);
        Cnt_Main.AutoScroll = true;
        Cnt_Main.Resize += (object sender, System.EventArgs e) =>
        {
            Cnt_Main.AutoScrollMinSize = Cnt_Main.PreferredSize;
            ConsoleLogger.Log ("PnlN Size : " + Pnl_Names.Size);
            //ConsoleLogger.Log("PnlS Size : " + Pnl_Summaries.Size);
            //ConsoleLogger.Log("PnlA Size : " + Pnl_Attributes.Size);
        };
        #endregion
        #region Cnt_CharID
        Cnt_CharID.AutoSize = true;
        Cnt_CharID.Dock = DockStyle.Fill;
        Cnt_CharID.ColumnCount = 2;
        Cnt_CharID.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
        Cnt_CharID.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
        Cnt_CharID.RowCount = 1;
        Cnt_CharID.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Cnt_CharID.TabIndex = 1;
        Cnt_CharID.Controls.Add (this.Lbl_CharID, 0, 0);
        Cnt_CharID.Controls.Add (this.Txt_CharID, 1, 0);
        #endregion
        #region Lbl_CharID
        this.Lbl_CharID.AutoSize = true;
        this.Lbl_CharID.Dock = DockStyle.Fill;
        this.Lbl_CharID.TabIndex = 1;
        this.Lbl_CharID.Text = Locale.Language.Strings.Tab_Editor_Character_Label_ID;
        this.Lbl_CharID.TextAlign = ContentAlignment.MiddleCenter;
        #endregion
        #region Txt_CharID
        this.Txt_CharID.AutoSize = true;
        this.Txt_CharID.Dock = DockStyle.Fill;
        this.Txt_CharID.TabIndex = 2;
        #endregion
        #region Pnl_Names
        Pnl_Names.DebugPanel = true;
        Pnl_Names.Dock = DockStyle.Fill;
        Pnl_Names.TabIndex = 2;
        Pnl_Names.Controls.Add (Tbl_Names);
        Pnl_Names.Title = Locale.Language.Strings.Tab_Editor_Character_Panel_Names_Title;
        Pnl_Names.OnExpand += () =>
        {
            Cnt_Main.Size = Cnt_Main.PreferredSize;
        };
        Pnl_Names.OnCollapse += () =>
        {
            Cnt_Main.Size = Cnt_Main.PreferredSize;
        };
        #endregion
        #region Tbl_Names
        Tbl_Names.Dock = DockStyle.Fill;
        Tbl_Names.ColumnCount = 2;
        Tbl_Names.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
        Tbl_Names.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
        Tbl_Names.RowCount = 5;
        Tbl_Names.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Tbl_Names.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Tbl_Names.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Tbl_Names.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Tbl_Names.RowStyles.Add (new RowStyle (SizeType.AutoSize));
        Tbl_Names.Controls.Add (Lst_Names, 0, 0);
        Tbl_Names.Controls.Add (Txt_Names, 1, 0);
        Tbl_Names.Controls.Add (Cmb_Names_Class, 1, 1);
        Tbl_Names.Controls.Add (Dtp_Names_Begin, 1, 2);
        Tbl_Names.Controls.Add (Dtp_Names_End, 1, 3);
        Tbl_Names.Controls.Add (Btn_Names_Add, 0, 4);
        Tbl_Names.Controls.Add (Btn_Names_Remove, 1, 4);
        #endregion
        #region Lst_Names
        Tbl_Names.SetRowSpan (Lst_Names, 4);
        Lst_Names.Dock = DockStyle.Fill;
        #endregion
        #region Txt_Names
        Txt_Names.Dock = DockStyle.Fill;
        #endregion
        #region Cmb_Names_Class
        Cmb_Names_Class.Dock = DockStyle.Fill;
        #endregion
        #region Dtp_Names_Begin
        Dtp_Names_Begin.Dock = DockStyle.Fill;
        #endregion
        #region Dtp_Names_End
        Dtp_Names_End.Dock = DockStyle.Fill;
        #endregion
        #region Btn_Names_Add
        Btn_Names_Add.Dock = DockStyle.Fill;
        Btn_Names_Add.Text = Locale.Language.Strings.Button_Label_Add;
        #endregion
        #region Btn_Names_Remove
        Btn_Names_Remove.Dock = DockStyle.Fill;
        Btn_Names_Remove.Text = Locale.Language.Strings.Button_Label_Remove;
        #endregion
        #region Pnl_Summaries
        Pnl_Summaries.Dock = DockStyle.Fill;
        Pnl_Summaries.TabIndex = 3;
        Pnl_Summaries.Controls.Add (Tbl_Summaries);
        Pnl_Summaries.Title = Locale.Language.Strings.Tab_Editor_Character_Panel_Summaries_Title;
        Pnl_Summaries.OnExpand += () =>
        {
            Cnt_Main.Size = Cnt_Main.PreferredSize;
        };
        Pnl_Summaries.OnCollapse += () =>
        {
            Cnt_Main.Size = Cnt_Main.PreferredSize;
        };
        #endregion
        #region Pnl_Arrtibutes
        Pnl_Attributes.Dock = DockStyle.Fill;
        Pnl_Attributes.TabIndex = 4;
        Pnl_Attributes.Controls.Add (Tbl_Attributes);
        Pnl_Attributes.Title = Locale.Language.Strings.Tab_Editor_Character_Panel_Attributes_Title;
        Pnl_Attributes.OnExpand += () =>
        {
            Cnt_Main.Size = Cnt_Main.PreferredSize;
        };
        Pnl_Attributes.OnCollapse += () =>
        {
            Cnt_Main.Size = Cnt_Main.PreferredSize;
        };
        #endregion
        #region This
        this.Resize += (object sender, System.EventArgs e) =>
        {
            ConsoleLogger.Log ("Table Size : " + Cnt_Main.Size);
        };
        this.Controls.Add (Cnt_Main);
        this.PerformLayout ();
        this.ResumeLayout (false);
        #endregion
    }
// Sorry I'm not allowed to add more than 2 hyperlinks ! //