There is No PaddingF

There is Point and PointF, Size and SizeF, Rectangle and RectangleF, Padding and… wait, there is no PaddingF!

System.Drawing vs. System.Windows.Forms

The 2-D drawing functions in the System.Drawing namespace accept both integer and floating point measurements.  That’s why the main 2-D drawing structures have both int and float versions such as Point and PointF, respectively.

However, the Padding structure is defined separately in the System.Windows.Forms namespace where most 2-D measurements are in integers.  Hence, there is an integer Padding structure but no floating point PaddingF.

Left, Top, Right, Bottom

Another oddity about Padding is the default order of the measurements.  In standard HTML CSS, padding is defined in this order: Top, Right, Bottom, Left.  For example:

padding:25px 50px 75px 100px;

  • top padding is 25px
  • right padding is 50px
  • bottom padding is 75px
  • left padding is 100px

However in .NET, the Padding constructor arguments are defined in this order: Left, Top, Right, Bottom:

public Padding(
	int left,
	int top,
	int right,
	int bottom
)

For more information about Padding, be sure to check out this other C#411 article:

Padding: Like a Rectangle, but Not

Share and Enjoy:
  • Digg
  • Twitter
  • Facebook
  • Reddit
  • StumbleUpon
  • LinkedIn
  • Google Bookmarks
  • Slashdot