WeifenLuo DockContent最小尺寸不起作用

时间:2014-08-13 07:16:29

标签: c# winforms

嘿,我从WeifenLuo那里得到了一份继承DockContent的表格。

public partial class ImportForm : DockContent
{
    /// <summary>
    /// Initializes a new instance of the <see cref="ImportForm" /> class.
    /// Constructor for non modal import control window
    /// </summary>
    /// <param name="guiLogic">The GUI logic.</param>
    public ImportForm(GuiLogic guiLogic)
    {
        InitializeComponent();
        this.MinimumSize = new Size(400, 400);
    }
}

问题是当我运行程序时,我可以将我的ImportForm拖动到我想要的宽度和高度。有谁知道我做错了什么?

非常感谢!

1 个答案:

答案 0 :(得分:0)

您知道并喜爱的Windows窗体的功能 - 窗口不允许您将其调整到超出某些限制 - 尚未在WeifenLuo DockPanelSuite中实现。如果您需要此功能,则必须自行修改source code

如果这听起来像是太多的工作,也许只是处理调整大小事件将帮助您实现目标。这是一个例子:

public partial class ImportForm : DockContent
{
    /// <summary>
    /// Initializes a new instance of the <see cref="ImportForm" /> class.
    /// Constructor for non modal import control window
    /// </summary>
    /// <param name="guiLogic">The GUI logic.</param>
    public ImportForm(GuiLogic guiLogic)
    {
        InitializeComponent();
        this.MinimumSize = new Size(400, 400);
        this.Resize += new EventHandler(ResizeEvent);
    }

    // If the content won't display nicely, hide it
    private void ResizeEvent(object sender, EventArgs e)
    {
        this.Visible = this.Width > this.MinimumSize.Width && this.Height > this.MinimumSize.Height;
    }

}

希望这有帮助。