Control.GetPreferredSize(Size) Control.GetPreferredSize(Size) Control.GetPreferredSize(Size) Control.GetPreferredSize(Size) Method

定義

擷取可容納控制項之矩形區域的大小。Retrieves the size of a rectangular area into which a control can be fitted.

public:
 virtual System::Drawing::Size GetPreferredSize(System::Drawing::Size proposedSize);
public virtual System.Drawing.Size GetPreferredSize (System.Drawing.Size proposedSize);
abstract member GetPreferredSize : System.Drawing.Size -> System.Drawing.Size
override this.GetPreferredSize : System.Drawing.Size -> System.Drawing.Size
Public Overridable Function GetPreferredSize (proposedSize As Size) As Size

參數

proposedSize
Size Size Size Size

控制項的自訂大小區域。The custom-sized area for a control.

傳回

Size 類型的排序配對,代表矩形的寬度與高度。An ordered pair of type Size representing the width and height of a rectangle.

備註

的行為GetPreferredSize因控制項而異。The behavior of GetPreferredSize differs by control. LayoutEngine可能無法將傳回的大小指派給控制項。The LayoutEngine might be unable to assign the returned size to the control. 您可以傳回大於proposedSize參數中所指出之條件約束的大小,但應該隨著條件約束減少而proposedSize降低。You can return a size larger than the constraints indicated in the proposedSize parameter, but proposedSize should decrease as the constraint decreases. 例如, GetPreferredSize(new Size(100, 0))GetPreferredSize(new Size(200, 0))應超出。For example, GetPreferredSize(new Size(100, 0)) should not be wider than GetPreferredSize(new Size(200, 0)). 例外狀況是proposedSize 0 或Size.Empty的,其定義為無限制。The exception is a proposedSize of 0 or Size.Empty, which are defined as unconstrained.

適用於