SizeF Structure

 

Stores an ordered pair of floating-point numbers, typically the width and height of a rectangle.

Namespace:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

[SerializableAttribute]
[ComVisibleAttribute(true)]
[TypeConverterAttribute(typeof(SizeFConverter))]
public struct SizeF

NameDescription
System_CAPS_pubmethodSizeF(PointF)

Initializes a new instance of the SizeF structure from the specified PointF structure.

System_CAPS_pubmethodSizeF(Single, Single)

Initializes a new instance of the SizeF structure from the specified dimensions.

System_CAPS_pubmethodSizeF(SizeF)

Initializes a new instance of the SizeF structure from the specified existing SizeF structure.

NameDescription
System_CAPS_pubpropertyHeight

Gets or sets the vertical component of this SizeF structure.

System_CAPS_pubpropertyIsEmpty

Gets a value that indicates whether this SizeF structure has zero width and height.

System_CAPS_pubpropertyWidth

Gets or sets the horizontal component of this SizeF structure.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticAdd(SizeF, SizeF)

Adds the width and height of one SizeF structure to the width and height of another SizeF structure.

System_CAPS_pubmethodEquals(Object)

Tests to see whether the specified object is a SizeF structure with the same dimensions as this SizeF structure.(Overrides ValueType.Equals(Object).)

System_CAPS_pubmethodGetHashCode()

Returns a hash code for this Size structure.(Overrides ValueType.GetHashCode().)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticSubtract(SizeF, SizeF)

Subtracts the width and height of one SizeF structure from the width and height of another SizeF structure.

System_CAPS_pubmethodToPointF()

Converts a SizeF structure to a PointF structure.

System_CAPS_pubmethodToSize()

Converts a SizeF structure to a Size structure.

System_CAPS_pubmethodToString()

Creates a human-readable string that represents this SizeF structure.(Overrides ValueType.ToString().)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticEmpty

Gets a SizeF structure that has a Height and Width value of 0.

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticAddition(SizeF, SizeF)

Adds the width and height of one SizeF structure to the width and height of another SizeF structure.

System_CAPS_puboperatorSystem_CAPS_staticEquality(SizeF, SizeF)

Tests whether two SizeF structures are equal.

System_CAPS_puboperatorSystem_CAPS_staticExplicit(SizeF to PointF)

Converts the specified SizeF structure to a PointF structure.

System_CAPS_puboperatorSystem_CAPS_staticInequality(SizeF, SizeF)

Tests whether two SizeF structures are different.

System_CAPS_puboperatorSystem_CAPS_staticSubtraction(SizeF, SizeF)

Subtracts the width and height of one SizeF structure from the width and height of another SizeF structure.

The unit for a SizeF structure depends on the PageUnit and PageScale settings for the Graphics object that is used to draw.

The following code example adds a shadow to a ListBox by using the following members:

This example is designed to be used with a Windows Form. To run this example, paste this code into a form and call the AddShadow method when handling the form's Paint event. Verify that the form contains a ListBox named listBox1.

private void AddShadow(PaintEventArgs e)
{

    // Create two SizeF objects.
    SizeF shadowSize = listBox1.Size;
    SizeF addSize = new SizeF(10.5F, 20.8F);

    // Add them together and save the result in shadowSize.
    shadowSize = shadowSize + addSize;

    // Get the location of the ListBox and convert it to a PointF.
    PointF shadowLocation = listBox1.Location;

    // Add two points to get a new location.
    shadowLocation = shadowLocation + new Size(5, 5);

    // Create a rectangleF. 
    RectangleF rectFToFill = 
        new RectangleF(shadowLocation, shadowSize);

    // Create a custom brush using a semi-transparent color, and 
    // then fill in the rectangle.
    Color customColor = Color.FromArgb(50, Color.Gray);
    SolidBrush shadowBrush = new SolidBrush(customColor);
    e.Graphics.FillRectangles(shadowBrush, new RectangleF[]{rectFToFill});

    // Dispose of the brush.
    shadowBrush.Dispose();
}

.NET Framework
Available since 1.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: