Graphics.FillRectangle Método

Definición

Rellena el interior de un rectángulo especificado por un par de coordenadas, un valor de ancho y un valor de alto.

Sobrecargas

FillRectangle(Brush, Rectangle)

Rellena el interior de un rectángulo especificado por una estructura Rectangle.

FillRectangle(Brush, RectangleF)

Rellena el interior de un rectángulo especificado por una estructura RectangleF.

FillRectangle(Brush, Int32, Int32, Int32, Int32)

Rellena el interior de un rectángulo especificado por un par de coordenadas, un valor de ancho y un valor de alto.

FillRectangle(Brush, Single, Single, Single, Single)

Rellena el interior de un rectángulo especificado por un par de coordenadas, un valor de ancho y un valor de alto.

FillRectangle(Brush, Rectangle)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Rellena el interior de un rectángulo especificado por una estructura Rectangle.

public:
 void FillRectangle(System::Drawing::Brush ^ brush, System::Drawing::Rectangle rect);
public void FillRectangle (System.Drawing.Brush brush, System.Drawing.Rectangle rect);
member this.FillRectangle : System.Drawing.Brush * System.Drawing.Rectangle -> unit
Public Sub FillRectangle (brush As Brush, rect As Rectangle)

Parámetros

brush
Brush

Brush que determina las características del relleno.

rect
Rectangle

Estructura Rectangle que representa el rectángulo que se va a rellenar.

Excepciones

brush es null.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, que es un parámetro del Paint controlador de eventos. El código realiza la siguiente acción:

  • Crea un pincel azul sólido.

  • Crea un rectángulo.

  • Rellena el área rectangular en la pantalla.

public:
   void FillRectangleRectangle( PaintEventArgs^ e )
   {
      // Create solid brush.
      SolidBrush^ blueBrush = gcnew SolidBrush( Color::Blue );

      // Create rectangle.
      Rectangle rect = Rectangle(0,0,200,200);

      // Fill rectangle to screen.
      e->Graphics->FillRectangle( blueBrush, rect );
   }
private void FillRectangleRectangle(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create rectangle.
    Rectangle rect = new Rectangle(0, 0, 200, 200);

    // Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, rect);
}
Private Sub FillRectangleRectangle(ByVal e As PaintEventArgs)

    ' Create solid brush.
    Dim blueBrush As New SolidBrush(Color.Blue)

    ' Create rectangle.
    Dim rect As New Rectangle(0, 0, 200, 200)

    ' Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, rect)
End Sub

Comentarios

Este método rellena el interior del rectángulo definido por el rect parámetro , incluida la esquina superior izquierda especificada y hasta los bordes inferiores e inferiores calculados.

Se aplica a

FillRectangle(Brush, RectangleF)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Rellena el interior de un rectángulo especificado por una estructura RectangleF.

public:
 void FillRectangle(System::Drawing::Brush ^ brush, System::Drawing::RectangleF rect);
public void FillRectangle (System.Drawing.Brush brush, System.Drawing.RectangleF rect);
member this.FillRectangle : System.Drawing.Brush * System.Drawing.RectangleF -> unit
Public Sub FillRectangle (brush As Brush, rect As RectangleF)

Parámetros

brush
Brush

Brush que determina las características del relleno.

rect
RectangleF

Estructura RectangleF que representa el rectángulo que se va a rellenar.

Excepciones

brush es null.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, que es un parámetro del Paint controlador de eventos. El código realiza la siguiente acción:

  • Crea un pincel azul sólido.

  • Crea un rectángulo.

  • Rellena el área rectangular en la pantalla.

public:
   void FillRectangleRectangleF( PaintEventArgs^ e )
   {
      // Create solid brush.
      SolidBrush^ blueBrush = gcnew SolidBrush( Color::Blue );

      // Create rectangle.
      RectangleF rect = RectangleF(0.0F,0.0F,200.0F,200.0F);

      // Fill rectangle to screen.
      e->Graphics->FillRectangle( blueBrush, rect );
   }
private void FillRectangleRectangleF(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create rectangle.
    RectangleF rect = new RectangleF(0.0F, 0.0F, 200.0F, 200.0F);

    // Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, rect);
}
Private Sub FillRectangleRectangleF(ByVal e As PaintEventArgs)

    ' Create solid brush.
    Dim blueBrush As New SolidBrush(Color.Blue)

    ' Create rectangle.
    Dim rect As New RectangleF(0.0F, 0.0F, 200.0F, 200.0F)

    ' Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, rect)
End Sub

Comentarios

Este método rellena el interior del rectángulo definido por el rect parámetro , incluida la esquina superior izquierda especificada y hasta los bordes inferiores e inferiores calculados.

Se aplica a

FillRectangle(Brush, Int32, Int32, Int32, Int32)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Rellena el interior de un rectángulo especificado por un par de coordenadas, un valor de ancho y un valor de alto.

public:
 void FillRectangle(System::Drawing::Brush ^ brush, int x, int y, int width, int height);
public void FillRectangle (System.Drawing.Brush brush, int x, int y, int width, int height);
member this.FillRectangle : System.Drawing.Brush * int * int * int * int -> unit
Public Sub FillRectangle (brush As Brush, x As Integer, y As Integer, width As Integer, height As Integer)

Parámetros

brush
Brush

Brush que determina las características del relleno.

x
Int32

Coordenada x de la esquina superior izquierda del rectángulo que se va a rellenar.

y
Int32

Coordenada y de la esquina superior izquierda del rectángulo que se va a rellenar.

width
Int32

Ancho del rectángulo que se va a rellenar.

height
Int32

Alto del rectángulo que se va a rellenar.

Excepciones

brush es null.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, que es un parámetro del Paint controlador de eventos. El código realiza la siguiente acción:

  • Crea un pincel azul sólido.

  • Crea la ubicación y el tamaño de un rectángulo.

  • Rellena el área rectangular en la pantalla.

public:
   void FillRectangleInt( PaintEventArgs^ e )
   {
      // Create solid brush.
      SolidBrush^ blueBrush = gcnew SolidBrush( Color::Blue );

      // Create location and size of rectangle.
      int x = 0;
      int y = 0;
      int width = 200;
      int height = 200;

      // Fill rectangle to screen.
      e->Graphics->FillRectangle( blueBrush, x, y, width, height );
   }
private void FillRectangleInt(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create location and size of rectangle.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 200;

    // Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, x, y, width, height);
}
Private Sub FillRectangleInt(ByVal e As PaintEventArgs)

    ' Create solid brush.
    Dim blueBrush As New SolidBrush(Color.Blue)

    ' Create location and size of rectangle.
    Dim x As Integer = 0
    Dim y As Integer = 0
    Dim width As Integer = 200
    Dim height As Integer = 200

    ' Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, x, y, width, height)
End Sub

Comentarios

Este método rellena el interior del rectángulo definido por losx parámetros , ywidth, y height , incluida la esquina superior izquierda especificada y hasta los bordes inferiores e inferiores calculados.

Se aplica a

FillRectangle(Brush, Single, Single, Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Rellena el interior de un rectángulo especificado por un par de coordenadas, un valor de ancho y un valor de alto.

public:
 void FillRectangle(System::Drawing::Brush ^ brush, float x, float y, float width, float height);
public void FillRectangle (System.Drawing.Brush brush, float x, float y, float width, float height);
member this.FillRectangle : System.Drawing.Brush * single * single * single * single -> unit
Public Sub FillRectangle (brush As Brush, x As Single, y As Single, width As Single, height As Single)

Parámetros

brush
Brush

Brush que determina las características del relleno.

x
Single

Coordenada x de la esquina superior izquierda del rectángulo que se va a rellenar.

y
Single

Coordenada y de la esquina superior izquierda del rectángulo que se va a rellenar.

width
Single

Ancho del rectángulo que se va a rellenar.

height
Single

Alto del rectángulo que se va a rellenar.

Excepciones

brush es null.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, que es un parámetro del Paint controlador de eventos. El código realiza la siguiente acción:

  • Crea un pincel azul sólido.

  • Crea la ubicación y el tamaño de un rectángulo.

  • Rellena el área rectangular en la pantalla.

public:
   void FillRectangleFloat( PaintEventArgs^ e )
   {
      // Create solid brush.
      SolidBrush^ blueBrush = gcnew SolidBrush( Color::Blue );

      // Create location and size of rectangle.
      float x = 0.0F;
      float y = 0.0F;
      float width = 200.0F;
      float height = 200.0F;

      // Fill rectangle to screen.
      e->Graphics->FillRectangle( blueBrush, x, y, width, height );
   }
private void FillRectangleFloat(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create location and size of rectangle.
    float x = 0.0F;
    float y = 0.0F;
    float width = 200.0F;
    float height = 200.0F;

    // Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, x, y, width, height);
}
Private Sub FillRectangleFloat(ByVal e As PaintEventArgs)

    ' Create solid brush.
    Dim blueBrush As New SolidBrush(Color.Blue)

    ' Create location and size of rectangle.
    Dim x As Single = 0.0F
    Dim y As Single = 0.0F
    Dim width As Single = 200.0F
    Dim height As Single = 200.0F

    ' Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, x, y, width, height)
End Sub

Comentarios

Este método rellena el interior del rectángulo definido por los xparámetros , y, widthy height , incluida la esquina superior izquierda especificada y hasta los bordes inferiores e inferiores calculados.

Se aplica a