FlowLayoutPanel问题 [英] FlowLayoutPanel issues

查看:141
本文介绍了FlowLayoutPanel问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在FlowLayoutPanel上很难过.

I'm having a really hard time with the FlowLayoutPanel.

我有一个带有一个子控件的FLP(FlowLayoutPanel)的Winforms应用程序-一个tabControl(其中带有一个webBrowser). 该窗体还在顶部停靠了一个TableLayoutPanel,在底部停靠了另一个TableLayoutPanel.因此,我的目的是用FlowLayoutPanel填充这些TLP之间的空间. 所有控件都将添加到设计视图的表单中.

I have a Winforms app with a FLP(FlowLayoutPanel) with one child control - a tabControl(with a webBrowser in it). The form also has a TableLayoutPanel docked on top, and another TableLayoutPanel docked at the bottom. So my intention is to fill the space between these TLP's with the FlowLayoutPanel. All controls are added to the form in design view.

我需要的-调整表单大小时,FLP应该很好地调整大小,填充表单,而tabControl也应填充FLP.

What I need - when I resize the form, the FLP should resize nicely with it, filling the form, and the tabControl should fill the FLP too.

该表单设置为最大化运行,因此默认情况下,在我运行该应用程序时会首先进行第一次调整大小-那时,除非我专门打电话给Form_Layout事件处理程序,否则FLP及其控件不会调整大小.

The form is set to run maximized, so a first resize happens by default when I run the app - at that point, the FLP and its control do not resize unless I tel them specifically to do so, in the Form_Layout event handler.

问题是,无论我在该事件处理程序中尝试使用的大小更改,锚定,码头的哪种组合,tabControl的顶部或底部始终不在窗体区域内,并且我看不到完整的滚动条其中的网络浏览器;因此,即使我告诉我,Tab控件也没有正确地停靠在FLP内部(或者FLP没有停靠在窗体中).这是Form_layout代码:

The problem is that no matter what combination of Size changes, Anchors, Docks I try in that event handler, always the top or bottom part of the tabControl is out of the form area and I can't see the full scroll bar of the webbrowser in it; so the tab control is not properly docked inside the FLP(or the FLP is not docked in the form), even if I tell it to be. Here is the Form_layout code:

private void MyForm_Layout(object sender, LayoutEventArgs e)
{
    //resize FLP
    pnlMainFlowLayout.Size = this.Size - new Size(15, 0);
    pnlMainFlowLayout.Dock = DockStyle.Fill;
    pnlMainFlowLayout.BringToFront();

    //resize child control of FLP
    tabControl.Size = pnlMainFlowLayout.Size;
    tabControl.BringToFront();
}

我真的需要了解FlowLayoutPanel的大小调整行为.

I really need to understand the FlowLayoutPanel's resizing behaviour.

推荐答案

如果FLP仅包含一个控件,则没有意义.它的工作是在其中流动控件,如果只有一个控件,则什么也不会流动.

There is no point in using a FLP if it contains only one control. Its job is to flow the controls inside of it, nothing to flow if there's only one.

照原样使用TabControl,将其Dock属性设置为Fill.如果这样会使它与TLP之一重叠,则右键单击该TLP,然后单击发送回".

Use the TabControl as-is, set its Dock property to Fill. If that make it overlap one of the TLPs then right-click the TLP and click 'Send To Back'.

这篇关于FlowLayoutPanel问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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