Point Implicit Conversion (Point to PointF)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Converts the specified Point structure to a PointF structure.

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

static operator PointF (
	Point p


Type: System.Drawing::Point

The Point to be converted.

Return Value

Type: System.Drawing::PointF

The PointF that results from the conversion.

The following code example adds a shadow to a ListBox using overloaded operators.

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. Be sure that the form contains a ListBox named listBox1.

   void AddShadow( PaintEventArgs^ e )
      // Create two SizeF objects.
      SizeF shadowSize = listBox1->Size;
      SizeF addSize = 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 + System::Drawing::Size( 5, 5 );

      // Create a rectangleF. 
      RectangleF rectFToFill = 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 = gcnew SolidBrush( customColor );
      array<RectangleF>^ temp0 = {rectFToFill};
      e->Graphics->FillRectangles( shadowBrush, temp0 );

      // Dispose of the brush.
      delete shadowBrush;

.NET Framework
Available since 1.1
Return to top