ButtonBase.GetPreferredSize(Size) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves the size of a rectangular area into which a control can be fitted.
public:
override System::Drawing::Size GetPreferredSize(System::Drawing::Size proposedSize);
public override System.Drawing.Size GetPreferredSize(System.Drawing.Size proposedSize);
override this.GetPreferredSize : System.Drawing.Size -> System.Drawing.Size
Public Overrides Function GetPreferredSize (proposedSize As Size) As Size
- proposedSize
- Size
The custom-sized area for a control.
An ordered pair of type Size representing the width and height of a rectangle.
The behavior of GetPreferredSize differs by control. The LayoutEngine might be unable to assign the returned size to the control. You can return a size larger than the constraints indicated in the proposedSize
parameter, but proposedSize
should decrease as the constraint decreases. For example, GetPreferredSize(new Size(100, 0))
should not be wider than GetPreferredSize(new Size(200, 0))
. The exception is a proposedSize
of 0 or Size.Empty
, which are defined as unconstrained.
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: