表格布局和移动/隐藏控件

发布于 2024-11-25 03:57:09 字数 9064 浏览 1 评论 0原文

我有一个带有表格布局控件的表单。表格布局有 3 列和多行。

第一列包含一个标签,第二列是文本框、组合框或日期时间选择器。第三列包含一张图片,如果用户输入的信息包含错误,则该图片会打开或关闭。这是为了让他们能够看到自己填写错误或遗漏的字段。

第五行包含一个组合框,用户可以在其中选择要输入的交易类型。根据用户的选择,控件可能需要重新排列。

让我使用屏幕截图展示一个示例:

https://i.sstatic.net/OZmFH.png

这是正在运行的表单的标准版本,用户尚未选择交易类型。

现在,假设用户选择贷款付款。该表单将重新排列以显示以下内容:

https://i.sstatic.net/j76wG.png< /a>

您可以看到叙述和总额已向下移动几行,并且显示了一个新框,允许用户选择贷款和付款次数。

根据所选的交易类型,可以呈现 3 种不同的布局。

现在,我通过检查事务类型组合框上的 SelectedIndexChanged 事件来执行此操作,然后调用一个方法来设置视图。

实现这一目标的最佳方法是什么?现在我有代码可以做到这一点,但它非常混乱。

除了表格布局面板之外,我还应该看看其他东西吗?

    readonly TableLayoutPanelCellPosition tlCCccLbl = new TableLayoutPanelCellPosition(0, 5);
    readonly TableLayoutPanelCellPosition tlCCccList = new TableLayoutPanelCellPosition(1, 5);
    readonly TableLayoutPanelCellPosition tlCCccError = new TableLayoutPanelCellPosition(2, 5);

    readonly TableLayoutPanelCellPosition tlCCnarrativeLbl = new TableLayoutPanelCellPosition(0, 6);
    readonly TableLayoutPanelCellPosition tlCCnarrativeTxt = new TableLayoutPanelCellPosition(1, 6);

    readonly TableLayoutPanelCellPosition tlCCgrossLbl = new TableLayoutPanelCellPosition(0, 7);
    readonly TableLayoutPanelCellPosition tlCCgrossTxt = new TableLayoutPanelCellPosition(1, 7);
    readonly TableLayoutPanelCellPosition tlCCgrossError = new TableLayoutPanelCellPosition(2, 7);

    readonly TableLayoutPanelCellPosition tlStdnarrativeLbl = new TableLayoutPanelCellPosition(0, 5);
    readonly TableLayoutPanelCellPosition tlStdnarrativeTxt = new TableLayoutPanelCellPosition(1, 5);

    readonly TableLayoutPanelCellPosition tlStdgrossLbl = new TableLayoutPanelCellPosition(0, 6);
    readonly TableLayoutPanelCellPosition tlStdgrossTxt = new TableLayoutPanelCellPosition(1, 6);
    readonly TableLayoutPanelCellPosition tlStdgrossError = new TableLayoutPanelCellPosition(2, 6);

    readonly TableLayoutPanelCellPosition tlStdLoanPymntsLbl = new TableLayoutPanelCellPosition(0, 8);
    readonly TableLayoutPanelCellPosition tlStdLoanPymntsCmb = new TableLayoutPanelCellPosition(1, 8);
    readonly TableLayoutPanelCellPosition tlStdLoanPymntsError = new TableLayoutPanelCellPosition(2, 8);

    readonly TableLayoutPanelCellPosition tlStdLoanLbl = new TableLayoutPanelCellPosition(0, 9);
    readonly TableLayoutPanelCellPosition tlStdLoanError = new TableLayoutPanelCellPosition(2, 9);
    readonly TableLayoutPanelCellPosition tlStdccLbl = new TableLayoutPanelCellPosition(0, 10);
    readonly TableLayoutPanelCellPosition tlStdccList = new TableLayoutPanelCellPosition(1, 10);
    readonly TableLayoutPanelCellPosition tlStdccError = new TableLayoutPanelCellPosition(2, 10);

    readonly TableLayoutPanelCellPosition tlLnLoanLbl = new TableLayoutPanelCellPosition(0, 5);
    readonly TableLayoutPanelCellPosition tlLnLoanCmb = new TableLayoutPanelCellPosition(1, 5);
    readonly TableLayoutPanelCellPosition tlLnLoanError = new TableLayoutPanelCellPosition(2, 5);

    readonly TableLayoutPanelCellPosition tlLnLoanPymntsLbl = new TableLayoutPanelCellPosition(0, 6);
    readonly TableLayoutPanelCellPosition tlLnLoanPymntsCmb = new TableLayoutPanelCellPosition(1, 6);
    readonly TableLayoutPanelCellPosition tlLnLoanPymntsError = new TableLayoutPanelCellPosition(2, 6);

    readonly TableLayoutPanelCellPosition tlLnnarrativeLbl = new TableLayoutPanelCellPosition(0, 7);
    readonly TableLayoutPanelCellPosition tlLnnarrativeTxt = new TableLayoutPanelCellPosition(1, 7);

    readonly TableLayoutPanelCellPosition tlLngrossLbl = new TableLayoutPanelCellPosition(0, 8);
    readonly TableLayoutPanelCellPosition tlLngrossTxt = new TableLayoutPanelCellPosition(1, 8);
    readonly TableLayoutPanelCellPosition tlLngrossError = new TableLayoutPanelCellPosition(2, 8);

    private void cmbTransactionType_SelectedIndexChanged(object sender, EventArgs e)
    {
        ToggleLoanControls(false);
        ToggleCreditCardControls(false);
        ToggleReceiptNumbers();

        if (clsTransactionTypes.TransactionStringToTransactionID(cmbTransactionType.Text) == clsTransactionTypes.LoanPayments || clsTransactionTypes.TransactionStringToTransactionID(cmbTransactionType.Text) == clsTransactionTypes.HpPayment)
             ToggleLoanControls(true);
        else if(clsTransactionTypes.TransactionStringToTransactionID(cmbTransactionType.Text) == clsTransactionTypes.TransferToCreditCardCard)
            ToggleCreditCardControls(true);

        SetupViews(cmbTransactionType.Text);
    }

    private void SetupViews(string transactionTypeSelected)
    {
         if (transactionTypeSelected == "Payment to Credit Card")
            SetupCreditCardsLayouts();
        else if(transactionTypeSelected == "HP Payment" || transactionTypeSelected == "Loan Payment")
            SetupLoanLayouts();
        else
            SetupStandardLayouts();
    }

    private void SetupLoanLayouts()
    {
        tableBank1Income.SetCellPosition(panelLoans, tlLnLoanCmb);
        tableBank1Income.SetCellPosition(lblLoans, tlLnLoanLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanName, tlLnLoanError);

        tableBank1Income.SetCellPosition(cmbNumberOfLoanPayments, tlLnLoanPymntsCmb);
        tableBank1Income.SetCellPosition(lblLoanPayments, tlLnLoanPymntsLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanPayments, tlLnLoanPymntsError);

        tableBank1Income.SetCellPosition(txtTransactionGross, tlLngrossTxt);
        tableBank1Income.SetCellPosition(lblTransactionAmount, tlLngrossLbl);
        tableBank1Income.SetCellPosition(lblErrorTransactionGross, tlLngrossError);

        tableBank1Income.SetCellPosition(txtTransactionNarrative, tlLnnarrativeTxt);
        tableBank1Income.SetCellPosition(lblTransactionNarrative, tlLnnarrativeLbl);

        tableBank1Income.SetCellPosition(panelCreditCards, tlStdccList);
        tableBank1Income.SetCellPosition(lblCreditCard, tlStdccLbl);
        tableBank1Income.SetCellPosition(lblCCError, tlStdccError);

    }

    private void SetupStandardLayouts()
    {
        tableBank1Income.SetCellPosition(txtTransactionGross, tlStdgrossTxt);
        tableBank1Income.SetCellPosition(lblTransactionAmount, tlStdgrossLbl);
        tableBank1Income.SetCellPosition(lblErrorTransactionGross, tlStdgrossError);

        tableBank1Income.SetCellPosition(txtTransactionNarrative, tlStdnarrativeTxt);
        tableBank1Income.SetCellPosition(lblTransactionNarrative, tlStdnarrativeLbl);

        tableBank1Income.SetCellPosition(txtTransactionGross, tlStdgrossTxt);
        tableBank1Income.SetCellPosition(lblTransactionAmount, tlStdgrossLbl);
        tableBank1Income.SetCellPosition(lblErrorTransactionGross, tlStdgrossError);

        tableBank1Income.SetCellPosition(panelLoans, tlStdLoanLbl);
        tableBank1Income.SetCellPosition(lblLoans, tlStdLoanLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanName, tlStdLoanError);

        tableBank1Income.SetCellPosition(cmbNumberOfLoanPayments, tlStdLoanPymntsCmb);
        tableBank1Income.SetCellPosition(lblLoanPayments, tlStdLoanPymntsLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanPayments, tlStdLoanPymntsError);

        tableBank1Income.SetCellPosition(panelCreditCards, tlStdccList);
        tableBank1Income.SetCellPosition(lblCreditCard, tlStdccLbl);
        tableBank1Income.SetCellPosition(lblCCError, tlStdccError);

        lblCCError.Visible = false;
        lblErrorLoanName.Visible = false;
        lblErrorLoanPayments.Visible = false;
    }

    private void SetupCreditCardsLayouts()
    {
        tableBank1Income.SetCellPosition(panelCreditCards, tlCCccList);
        tableBank1Income.SetCellPosition(lblCreditCard, tlCCccLbl);
        tableBank1Income.SetCellPosition(lblCCError, tlCCccError);

        tableBank1Income.SetCellPosition(txtTransactionGross, tlCCgrossTxt);
        tableBank1Income.SetCellPosition(lblTransactionAmount, tlCCgrossLbl);
        tableBank1Income.SetCellPosition(lblErrorTransactionGross, tlCCgrossError);

        tableBank1Income.SetCellPosition(txtTransactionNarrative, tlCCnarrativeTxt);  
        tableBank1Income.SetCellPosition(lblTransactionNarrative, tlCCnarrativeLbl);

        tableBank1Income.SetCellPosition(panelLoans, tlStdLoanLbl);
        tableBank1Income.SetCellPosition(lblLoans, tlStdLoanLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanName, tlStdLoanError);

        tableBank1Income.SetCellPosition(cmbNumberOfLoanPayments, tlStdLoanPymntsCmb);
        tableBank1Income.SetCellPosition(lblLoanPayments, tlStdLoanPymntsLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanPayments, tlStdLoanPymntsError);

     }

该代码的工作原理是将不需要的控件移动到表格底部,并将需要的控件向上移动。这样表格中就没有间隙。例如,我不想只打开和关闭贷款组合框的可见性,因为这样的话交易类型和两行的叙述之间就会存在间隙。我总是希望它尽可能紧凑。

当前系统的唯一问题是底部有包含不可见控件的空行。添加行也很困难,因为我必须去更改所有处理移动内容的代码。

感谢您的阅读,如果您读到这里。

有一个>唷<

谢谢

未列出切换控件方法。他们基本上打开/关闭不需要可见性的控件。

I have a form which has a table layout control on it. The table layout has 3 columns and a number of rows.

The first column contains a label, the second is either a textbox, comboBox or date time picker. The third column contains a picture which is toggled on or off if the information the user has entered contains errors. This is to allow them to see which fields they have filled in wrongly or missed.

The fifth row contains a comboBox where the user can select which type of transaction they are entering. Depending on what the user selects the controls may have to re-arrange themselves.

Let me show an example using screenshots:

https://i.sstatic.net/OZmFH.png

This is a standard version of the form running, the user hasn't selected a transaction type.

Now, let's say the user selects a Loan Payment. The form would re-arrange to show the following:

https://i.sstatic.net/j76wG.png

You can see the narrative and gross have moved down a couple of rows and a new box has been shown to allow the user to select a loan and the number of payments being made.

There are 3 different layouts that can be presented depending on the transaction type selected.

Right now I do this by checking for the SelectedIndexChanged event on the Transaction Type comboBox and I call a method to setup the view.

What would be the best way to achieve this ? Right now I have code that does it, but it's incredibly messy.

Should I look at something other than a table layout panel ?

    readonly TableLayoutPanelCellPosition tlCCccLbl = new TableLayoutPanelCellPosition(0, 5);
    readonly TableLayoutPanelCellPosition tlCCccList = new TableLayoutPanelCellPosition(1, 5);
    readonly TableLayoutPanelCellPosition tlCCccError = new TableLayoutPanelCellPosition(2, 5);

    readonly TableLayoutPanelCellPosition tlCCnarrativeLbl = new TableLayoutPanelCellPosition(0, 6);
    readonly TableLayoutPanelCellPosition tlCCnarrativeTxt = new TableLayoutPanelCellPosition(1, 6);

    readonly TableLayoutPanelCellPosition tlCCgrossLbl = new TableLayoutPanelCellPosition(0, 7);
    readonly TableLayoutPanelCellPosition tlCCgrossTxt = new TableLayoutPanelCellPosition(1, 7);
    readonly TableLayoutPanelCellPosition tlCCgrossError = new TableLayoutPanelCellPosition(2, 7);

    readonly TableLayoutPanelCellPosition tlStdnarrativeLbl = new TableLayoutPanelCellPosition(0, 5);
    readonly TableLayoutPanelCellPosition tlStdnarrativeTxt = new TableLayoutPanelCellPosition(1, 5);

    readonly TableLayoutPanelCellPosition tlStdgrossLbl = new TableLayoutPanelCellPosition(0, 6);
    readonly TableLayoutPanelCellPosition tlStdgrossTxt = new TableLayoutPanelCellPosition(1, 6);
    readonly TableLayoutPanelCellPosition tlStdgrossError = new TableLayoutPanelCellPosition(2, 6);

    readonly TableLayoutPanelCellPosition tlStdLoanPymntsLbl = new TableLayoutPanelCellPosition(0, 8);
    readonly TableLayoutPanelCellPosition tlStdLoanPymntsCmb = new TableLayoutPanelCellPosition(1, 8);
    readonly TableLayoutPanelCellPosition tlStdLoanPymntsError = new TableLayoutPanelCellPosition(2, 8);

    readonly TableLayoutPanelCellPosition tlStdLoanLbl = new TableLayoutPanelCellPosition(0, 9);
    readonly TableLayoutPanelCellPosition tlStdLoanError = new TableLayoutPanelCellPosition(2, 9);
    readonly TableLayoutPanelCellPosition tlStdccLbl = new TableLayoutPanelCellPosition(0, 10);
    readonly TableLayoutPanelCellPosition tlStdccList = new TableLayoutPanelCellPosition(1, 10);
    readonly TableLayoutPanelCellPosition tlStdccError = new TableLayoutPanelCellPosition(2, 10);

    readonly TableLayoutPanelCellPosition tlLnLoanLbl = new TableLayoutPanelCellPosition(0, 5);
    readonly TableLayoutPanelCellPosition tlLnLoanCmb = new TableLayoutPanelCellPosition(1, 5);
    readonly TableLayoutPanelCellPosition tlLnLoanError = new TableLayoutPanelCellPosition(2, 5);

    readonly TableLayoutPanelCellPosition tlLnLoanPymntsLbl = new TableLayoutPanelCellPosition(0, 6);
    readonly TableLayoutPanelCellPosition tlLnLoanPymntsCmb = new TableLayoutPanelCellPosition(1, 6);
    readonly TableLayoutPanelCellPosition tlLnLoanPymntsError = new TableLayoutPanelCellPosition(2, 6);

    readonly TableLayoutPanelCellPosition tlLnnarrativeLbl = new TableLayoutPanelCellPosition(0, 7);
    readonly TableLayoutPanelCellPosition tlLnnarrativeTxt = new TableLayoutPanelCellPosition(1, 7);

    readonly TableLayoutPanelCellPosition tlLngrossLbl = new TableLayoutPanelCellPosition(0, 8);
    readonly TableLayoutPanelCellPosition tlLngrossTxt = new TableLayoutPanelCellPosition(1, 8);
    readonly TableLayoutPanelCellPosition tlLngrossError = new TableLayoutPanelCellPosition(2, 8);

    private void cmbTransactionType_SelectedIndexChanged(object sender, EventArgs e)
    {
        ToggleLoanControls(false);
        ToggleCreditCardControls(false);
        ToggleReceiptNumbers();

        if (clsTransactionTypes.TransactionStringToTransactionID(cmbTransactionType.Text) == clsTransactionTypes.LoanPayments || clsTransactionTypes.TransactionStringToTransactionID(cmbTransactionType.Text) == clsTransactionTypes.HpPayment)
             ToggleLoanControls(true);
        else if(clsTransactionTypes.TransactionStringToTransactionID(cmbTransactionType.Text) == clsTransactionTypes.TransferToCreditCardCard)
            ToggleCreditCardControls(true);

        SetupViews(cmbTransactionType.Text);
    }

    private void SetupViews(string transactionTypeSelected)
    {
         if (transactionTypeSelected == "Payment to Credit Card")
            SetupCreditCardsLayouts();
        else if(transactionTypeSelected == "HP Payment" || transactionTypeSelected == "Loan Payment")
            SetupLoanLayouts();
        else
            SetupStandardLayouts();
    }

    private void SetupLoanLayouts()
    {
        tableBank1Income.SetCellPosition(panelLoans, tlLnLoanCmb);
        tableBank1Income.SetCellPosition(lblLoans, tlLnLoanLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanName, tlLnLoanError);

        tableBank1Income.SetCellPosition(cmbNumberOfLoanPayments, tlLnLoanPymntsCmb);
        tableBank1Income.SetCellPosition(lblLoanPayments, tlLnLoanPymntsLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanPayments, tlLnLoanPymntsError);

        tableBank1Income.SetCellPosition(txtTransactionGross, tlLngrossTxt);
        tableBank1Income.SetCellPosition(lblTransactionAmount, tlLngrossLbl);
        tableBank1Income.SetCellPosition(lblErrorTransactionGross, tlLngrossError);

        tableBank1Income.SetCellPosition(txtTransactionNarrative, tlLnnarrativeTxt);
        tableBank1Income.SetCellPosition(lblTransactionNarrative, tlLnnarrativeLbl);

        tableBank1Income.SetCellPosition(panelCreditCards, tlStdccList);
        tableBank1Income.SetCellPosition(lblCreditCard, tlStdccLbl);
        tableBank1Income.SetCellPosition(lblCCError, tlStdccError);

    }

    private void SetupStandardLayouts()
    {
        tableBank1Income.SetCellPosition(txtTransactionGross, tlStdgrossTxt);
        tableBank1Income.SetCellPosition(lblTransactionAmount, tlStdgrossLbl);
        tableBank1Income.SetCellPosition(lblErrorTransactionGross, tlStdgrossError);

        tableBank1Income.SetCellPosition(txtTransactionNarrative, tlStdnarrativeTxt);
        tableBank1Income.SetCellPosition(lblTransactionNarrative, tlStdnarrativeLbl);

        tableBank1Income.SetCellPosition(txtTransactionGross, tlStdgrossTxt);
        tableBank1Income.SetCellPosition(lblTransactionAmount, tlStdgrossLbl);
        tableBank1Income.SetCellPosition(lblErrorTransactionGross, tlStdgrossError);

        tableBank1Income.SetCellPosition(panelLoans, tlStdLoanLbl);
        tableBank1Income.SetCellPosition(lblLoans, tlStdLoanLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanName, tlStdLoanError);

        tableBank1Income.SetCellPosition(cmbNumberOfLoanPayments, tlStdLoanPymntsCmb);
        tableBank1Income.SetCellPosition(lblLoanPayments, tlStdLoanPymntsLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanPayments, tlStdLoanPymntsError);

        tableBank1Income.SetCellPosition(panelCreditCards, tlStdccList);
        tableBank1Income.SetCellPosition(lblCreditCard, tlStdccLbl);
        tableBank1Income.SetCellPosition(lblCCError, tlStdccError);

        lblCCError.Visible = false;
        lblErrorLoanName.Visible = false;
        lblErrorLoanPayments.Visible = false;
    }

    private void SetupCreditCardsLayouts()
    {
        tableBank1Income.SetCellPosition(panelCreditCards, tlCCccList);
        tableBank1Income.SetCellPosition(lblCreditCard, tlCCccLbl);
        tableBank1Income.SetCellPosition(lblCCError, tlCCccError);

        tableBank1Income.SetCellPosition(txtTransactionGross, tlCCgrossTxt);
        tableBank1Income.SetCellPosition(lblTransactionAmount, tlCCgrossLbl);
        tableBank1Income.SetCellPosition(lblErrorTransactionGross, tlCCgrossError);

        tableBank1Income.SetCellPosition(txtTransactionNarrative, tlCCnarrativeTxt);  
        tableBank1Income.SetCellPosition(lblTransactionNarrative, tlCCnarrativeLbl);

        tableBank1Income.SetCellPosition(panelLoans, tlStdLoanLbl);
        tableBank1Income.SetCellPosition(lblLoans, tlStdLoanLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanName, tlStdLoanError);

        tableBank1Income.SetCellPosition(cmbNumberOfLoanPayments, tlStdLoanPymntsCmb);
        tableBank1Income.SetCellPosition(lblLoanPayments, tlStdLoanPymntsLbl);
        tableBank1Income.SetCellPosition(lblErrorLoanPayments, tlStdLoanPymntsError);

     }

The code works by moving the controls that aren't needed to the bottom of the table and moving those that are needed up. That way there are no gaps in the table. e.g. I wouldn't want to just turn the visibility of Loan combobox on and off because then there would be a gap between the transaction type and narrative of two rows. I always want it as compact as possible.

Only problem with the current system is there are empty rows at the bottom containing invisible controls. It's also difficult to add rows as I have to go and change all the code which deals with moving stuff around.

Thanks for reading, if you go this far.

Have a >phew<

Thanks

The toggle controls methods aren't listed. They basically turn the controls that aren't need visibility on / off.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

养猫人 2024-12-02 03:57:09

我发现自己偶尔会遇到类似的情况,并且更喜欢一种不太混乱的方法:

  1. 首先,您的屏幕截图似乎表明一列就足够了,因为第一列的宽度已经“固定”,并带有长标签“交易金额(总金额)” )”。因此删除一列。
  2. 将每个标签/文本框对放入其自己的(常规)面板中。所以每行一个面板。 (由于左侧“列”宽度是固定的,因此您可以使所有面板具有相同的宽度并确保文本框对齐。)
  3. 将所有面板添加到 TableLayoutPanel。
  4. 将 TableLayoutPanel 的所有行的高度设置为“自动大小”。为 TableLayoutPanel 设置 AutoSize=true 和 AutoSizeMode=GrowAndShrink。

要调整表单的布局,您现在只需设置 9 个面板的 Visible- 属性。如果面板被隐藏,则表格布局的整行将因自动调整行大小而消失,而其他行将向上移动。如果您出现新行,则相同。因此布局是自动化的,您只需要决定显示哪一行。

此外,TableLayoutPanel 现在将缩小到其内容。如果您愿意,您现在还可以使用包含表单的 AutoSize* 属性来使表单自动调整大小,但要小心,避免用这种行为打扰您的用户。您还可以处理 TableLayoutPanel 的 SizeChanged 事件,以根据需要调整表单的大小。

我希望我的描述是可以理解的,否则请随时询问详细信息。

I find myself in similar situations occasionally and prefer a less messy approach:

  1. First of all, your screenshot seems to indicate that one column would suffice, as the width of the first column is already "fixed" with the long label "Transaction Amount (Gross)". So remove one column.
  2. Put each Label/TextBox pair into its own (regular) Panel. So one Panel per row. (Since the left "column" width is fixed, you can make all Panels the same width and make sure the TextBoxes align.)
  3. Add all Panels to the TableLayoutPanel.
  4. Set the hight of all rows of the TableLayoutPanel to "auto size". Set AutoSize=true and AutoSizeMode=GrowAndShrink for the TableLayoutPanel.

To adjust the layout of your form, you now only need to set the Visible-property of the 9 Panels. If a Panel gets hidden, the entire row of the table layout will disappear because of the AutoSizing rows and the other rows will move up. Same if you make a new row appear. So the layout is automated, you only need to decide which row to show.

Also, the TableLayoutPanel will now shrink to its content. If you like, you can now also mess around with the AutoSize* properties of the containing form to make the form auto size, but be careful to avoid annoying your users with this behaviour. You could also handle the SizeChanged event of the TableLayoutPanel to adjust the size of your form as necessary.

I hope that my description is comprehensible, otherwise feel free to ask for details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文