【问题标题】:How to set vertical gap when DockStyle is set as Top in Winform? [duplicate]Winform中将DockStyle设置为Top时如何设置垂直间隙? [复制]
【发布时间】:2016-05-19 03:31:39
【问题描述】:

我有一个面板,我已将 DockStyle 设置为顶部,但我想设置像 (0, 10) 这样的开始位置,这意味着我想从顶部向下 10 个位置开始这个面板。我尝试了 Padding 和 Margin 但不起作用,更改 DockStyle 也不起作用。

this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
        this.panel1.Location = new System.Drawing.Point(0, 10);

【问题讨论】:

标签: c# winforms


【解决方案1】:

您应该将填充添加到包含panel1 的控件,而不是面板本身:

// using "this" assuming you're in a form that directly contains panel1
this.Padding = new System.Windows.Forms.Padding(0, 10, 0, 0);
panel1.Dock = System.Windows.Forms.DockStyle.Top;

【讨论】:

    猜你喜欢
    • 2019-10-03
    • 1970-01-01
    • 2015-03-28
    • 2011-12-21
    • 2019-07-31
    • 2011-01-18
    • 2012-01-30
    • 2014-12-26
    • 1970-01-01
    相关资源
    最近更新 更多