Padding Padding Padding Padding Struct

定義

表示與使用者介面 (UI) 項目有關聯的邊框距離或邊界資訊。Represents padding or margin information associated with a user interface (UI) element.

public value class Padding
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.PaddingConverter))]
[System.Serializable]
public struct Padding
type Padding = struct
Public Structure Padding
繼承
屬性

範例

下列程式碼範例示範如何使用 [填補] 屬性, 在RichTextBox控制項周圍建立外框。The following code example demonstrates how to use the Padding property to create an outline around a RichTextBox control.

如需完整的程式代碼清單, 請參閱如何:使用填補在 Windows Forms 控制項周圍建立框線。For a full code listing, see How to: Create a Border Around a Windows Forms Control Using Padding.

// This code example demonstrates using the Padding property to 
// create a border around a RichTextBox control.
public Form1()
{
    InitializeComponent();

    this.panel1.BackColor = System.Drawing.Color.Blue;
    this.panel1.Padding = new System.Windows.Forms.Padding(5);
    this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;

    this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
    this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
}
' This code example demonstrates using the Padding property to 
' create a border around a RichTextBox control.
Public Sub New()
     InitializeComponent()

     Me.panel1.BackColor = System.Drawing.Color.Blue
     Me.panel1.Padding = New System.Windows.Forms.Padding(5)
     Me.panel1.Dock = System.Windows.Forms.DockStyle.Fill

     Me.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None
     Me.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill
 End Sub

備註

Padding結構代表與矩形 UI 元素 (例如控制項) 相關聯的填補或邊界。The Padding structure represents the padding or margin associated with a rectangular UI element such as a control. 填補是 UI 元素和其邊緣之間的內部空間。The padding is the internal space between the body of the UI element and its edge. 相反地, 邊界是分隔兩個相鄰 UI 元素相鄰邊緣的距離。In contrast, a margin is the distance separating the adjoining edges of two adjacent UI elements. 由於結構相似, Padding會用來代表填補和邊界。Because of structural similarities, Padding is used to represent both padding and margins.

如需說明控制項上之PaddingMargin屬性的圖表, 請參閱Windows Forms 控制項中的邊界和填補For a diagram that illustrates the Padding and Margin properties on a control, see Margin and Padding in Windows Forms Controls.

對於容器而言, 填補與不是控制項的控制項有不同的影響。Padding has a different effect on controls that are containers than on controls that are not. 例如, 在Panel控制項中Padding , 屬性會定義的框線Panel與其子控制項之間的間距。For example, in a Panel control, the Padding property defines the spacing between the border of the Panel and its child controls. 針對控制項, 屬性會定義Button控制項的框線和其包含文字之間的間距。 Padding ButtonFor a Button control, the Padding property defines the spacing between the border of the Button control and its contained text.

除了一般的方法和屬性之外, Padding也會定義下列類型層級成員:In addition to typical methods and properties, Padding also defines the following type-level members:

  • 欄位, 代表預先定義Padding且不含填補的。 EmptyThe Empty field, which represents a predefined Padding with no padding.

  • 一組運算子, 用來執行類別的一般算數運算, 例如同時新增兩Padding個物件。A set of operators for performing common arithmetic operations for the class, such as adding two Padding objects together. 針對不支援運算子多載的語言, 您可以使用替代方法語法來叫用這些成員。For languages that do not support operator overloading, you can invoke these members by using alternative method syntax.

  • Horizontal、和屬性Size , 可提供方便在自訂版面配置計算中使用的結合值。 VerticalThe Horizontal, Vertical, and Size properties, which provide combined values that are convenient for use in custom layout calculations.

建構函式

Padding(Int32) Padding(Int32) Padding(Int32) Padding(Int32)

使用為所有邊緣所提供的邊框距離大小,初始化 Padding 類別的新執行個體。Initializes a new instance of the Padding class using the supplied padding size for all edges.

Padding(Int32, Int32, Int32, Int32) Padding(Int32, Int32, Int32, Int32) Padding(Int32, Int32, Int32, Int32) Padding(Int32, Int32, Int32, Int32)

使用每一個邊緣的個別邊框距離大小,初始化 Padding 類別的新執行個體。Initializes a new instance of the Padding class using a separate padding size for each edge.

欄位

Empty Empty Empty Empty

提供 Padding 物件,且無邊框距離。Provides a Padding object with no padding.

屬性

All All All All

取得或設定所有邊緣的邊框距離值。Gets or sets the padding value for all the edges.

Bottom Bottom Bottom Bottom

取得或設定下邊緣的邊框距離值。Gets or sets the padding value for the bottom edge.

Horizontal Horizontal Horizontal Horizontal

取得右邊緣和左邊緣的合併邊框距離。Gets the combined padding for the right and left edges.

Left Left Left Left

取得或設定左邊緣的邊框距離值。Gets or sets the padding value for the left edge.

Right Right Right Right

取得或設定右邊緣的邊框距離值。Gets or sets the padding value for the right edge.

Size Size Size Size

取得 Size 格式的邊框距離資訊。Gets the padding information in the form of a Size.

Top Top Top Top

取得或設定上邊緣的邊框距離值。Gets or sets the padding value for the top edge.

Vertical Vertical Vertical Vertical

取得上邊緣和下邊緣的合併邊框距離。Gets the combined padding for the top and bottom edges.

方法

Add(Padding, Padding) Add(Padding, Padding) Add(Padding, Padding) Add(Padding, Padding)

計算兩個指定之 Padding 值的總和。Computes the sum of the two specified Padding values.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定之物件的值是否與目前的 Padding 相等。Determines whether the value of the specified object is equivalent to the current Padding.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

產生目前 Padding 的雜湊程式碼。Generates a hash code for the current Padding.

Subtract(Padding, Padding) Subtract(Padding, Padding) Subtract(Padding, Padding) Subtract(Padding, Padding)

將另一個指定的 Padding 值減去某個值。Subtracts one specified Padding value from another.

ToString() ToString() ToString() ToString()

傳回字串,表示目前的 PaddingReturns a string that represents the current Padding.

運算子

Addition(Padding, Padding) Addition(Padding, Padding) Addition(Padding, Padding) Addition(Padding, Padding)

在兩個指定的 Padding 物件上執行向量加法,產生新的 PaddingPerforms vector addition on the two specified Padding objects, resulting in a new Padding.

Equality(Padding, Padding) Equality(Padding, Padding) Equality(Padding, Padding) Equality(Padding, Padding)

測試兩個指定的 Padding 物件是否相等。Tests whether two specified Padding objects are equivalent.

Inequality(Padding, Padding) Inequality(Padding, Padding) Inequality(Padding, Padding) Inequality(Padding, Padding)

測試兩個指定的 Padding 物件是否相等。Tests whether two specified Padding objects are not equivalent.

Subtraction(Padding, Padding) Subtraction(Padding, Padding) Subtraction(Padding, Padding) Subtraction(Padding, Padding)

在兩個指定的 Padding 物件上執行向量減法,產生新的 PaddingPerforms vector subtraction on the two specified Padding objects, resulting in a new Padding.

適用於

另請參閱