# C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.FillRectangle

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_" data-uid="C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.FillRectangle*">FillRectangle Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_" data-uid="C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.FillRectangle*"></a>
<h4 id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_System_Drawing_Color_System_Drawing_Color_System_Drawing_Rectangle_System_Boolean_" data-uid="C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.FillRectangle(System.Drawing.Color,System.Drawing.Color,System.Drawing.Rectangle,System.Boolean)">FillRectangle(Color, Color, Rectangle, bool)</h4>
<div class="markdown level1 summary"><p>Gradient fills the rectangle with colors.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void FillRectangle(Color startColor, Color endColor, Rectangle rectangle, bool verticalDirection)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub FillRectangle(startColor As Color, endColor As Color, rectangle As Rectangle, verticalDirection As Boolean)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.color">Color</a></td>
      <td><span class="parametername">startColor</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.color">Color</a> structure that represents the start color
of gradient.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.color">Color</a></td>
      <td><span class="parametername">endColor</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.color">Color</a> structure that represents the end color of
gradient.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a></td>
      <td><span class="parametername">rectangle</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a> structure that represents the rectangle
to fill.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">verticalDirection</span></td>
      <td><p>A <b>bool</b> indicates the fill direction.
<b>false</b> is horizontal direction. <b>true</b> is vertical direction.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_" data-uid="C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.FillRectangle*"></a>
<h4 id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_System_IntPtr_System_Drawing_Rectangle_" data-uid="C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.FillRectangle(System.IntPtr,System.Drawing.Rectangle)">FillRectangle(IntPtr, Rectangle)</h4>
<div class="markdown level1 summary"><p>Fills the specified rectangle by using the specified brush.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public virtual void FillRectangle(IntPtr brushHandle, Rectangle rectangle)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Overridable Sub FillRectangle(brushHandle As IntPtr, rectangle As Rectangle)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.intptr">IntPtr</a></td>
      <td><span class="parametername">brushHandle</span></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.intptr">IntPtr</a> indicates the handle of the brush.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a></td>
      <td><span class="parametername">rectangle</span></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a> indicate the rectangle to fill.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_System_IntPtr_System_Drawing_Rectangle__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>When filling the specified rectangle, it does not include the rectangle's right and bottom sides. GDI fills
a rectangle up to, but not including, the right column and bottom row, regardless of the current mapping mode.</p>
</div>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Condition</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Framework.SystemErrorException.html">SystemErrorException</a></td>
      <td></td>
    </tr>
  </tbody>
</table>


<a id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_" data-uid="C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.FillRectangle*"></a>
<h4 id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_System_Drawing_Rectangle_C1_Framework_Drawing_Gdi_DeviceContexts_RasterOperationCode_" data-uid="C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.FillRectangle(System.Drawing.Rectangle,C1.Framework.Drawing.Gdi.DeviceContexts.RasterOperationCode)">FillRectangle(Rectangle, RasterOperationCode)</h4>
<div class="markdown level1 summary"><p>Fills the specified rectangle by using the current brush of device context.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public virtual void FillRectangle(Rectangle rectangle, RasterOperationCode rasterOperationCode)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Overridable Sub FillRectangle(rectangle As Rectangle, rasterOperationCode As RasterOperationCode)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a></td>
      <td><span class="parametername">rectangle</span></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a> indicates the rectangle to fill.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Framework.Drawing.Gdi.DeviceContexts.RasterOperationCode.html">RasterOperationCode</a></td>
      <td><span class="parametername">rasterOperationCode</span></td>
      <td><p>A <a class="xref" href="C1.Framework.Drawing.Gdi.DeviceContexts.DeviceContext.RasterOperationCode.html#C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_RasterOperationCode">RasterOperationCode</a> indicates the rester operation code.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Framework_Drawing_Gdi_DeviceContexts_DeviceContext_FillRectangle_System_Drawing_Rectangle_C1_Framework_Drawing_Gdi_DeviceContexts_RasterOperationCode__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Not all devices support the this function. For more information, see the description of
the <b>RC_BITBLT</b> capability in the <b>GetDeviceCaps</b> function.</p>
</div>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Condition</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Framework.SystemErrorException.html">SystemErrorException</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
</div>
