# C1.Win.SuperTooltip.C1SuperLabelBase.DrawToGraphics

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_SuperTooltip_C1SuperLabelBase_DrawToGraphics_" data-uid="C1.Win.SuperTooltip.C1SuperLabelBase.DrawToGraphics*">DrawToGraphics Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_SuperTooltip_C1SuperLabelBase_DrawToGraphics_" data-uid="C1.Win.SuperTooltip.C1SuperLabelBase.DrawToGraphics*"></a>
<h4 id="C1_Win_SuperTooltip_C1SuperLabelBase_DrawToGraphics_System_Drawing_Graphics_System_Drawing_Rectangle_" data-uid="C1.Win.SuperTooltip.C1SuperLabelBase.DrawToGraphics(System.Drawing.Graphics,System.Drawing.Rectangle)">DrawToGraphics(Graphics, Rectangle)</h4>
<div class="markdown level1 summary"><p>Draws the control content into a given <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.graphics">Graphics</a> object.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void DrawToGraphics(Graphics g, Rectangle bounds)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub DrawToGraphics(g As Graphics, bounds 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.drawing.graphics">Graphics</a></td>
      <td><span class="parametername">g</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.graphics">Graphics</a> object where the content will be rendered.</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">bounds</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a> that specifies the bounds where the content will be rendered.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_SuperTooltip_C1SuperLabelBase_DrawToGraphics_System_Drawing_Graphics_System_Drawing_Rectangle__examples">Examples</h5>
<p>The example below uses the <b>DrawToGraphics</b> method to render Html in a <b>C1FlexGrid</b> control.
Grid cells containing text that starts with an &lt;html&gt; tag are rendered as Html. Other cells are
rendered by the grid as usual.</p>
<pre><code class="lang-csharp">void _flex_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
{
  // get cell content
  string text = _flex.GetDataDisplay(e.Row, e.Col);

  // check that the cell contains html
  if (!string.IsNullOrEmpty(text) &amp;&amp;
       text.StartsWith("&lt;html&gt;"))
  {
    // set label back color and content
    _superLabel.BackColor = e.Style.BackColor;
    _superLabel.Text = text;

    // draw the Html into grid cell
    _superLabel.DrawToGraphics(e.Graphics, e.Bounds);

    // cell has been drawn
    e.Handled = true;
  }
}</code></pre>



<a id="C1_Win_SuperTooltip_C1SuperLabelBase_DrawToGraphics_" data-uid="C1.Win.SuperTooltip.C1SuperLabelBase.DrawToGraphics*"></a>
<h4 id="C1_Win_SuperTooltip_C1SuperLabelBase_DrawToGraphics_System_Drawing_Graphics_System_Drawing_RectangleF_System_Int32_" data-uid="C1.Win.SuperTooltip.C1SuperLabelBase.DrawToGraphics(System.Drawing.Graphics,System.Drawing.RectangleF,System.Int32)">DrawToGraphics(Graphics, RectangleF, int)</h4>
<div class="markdown level1 summary"><p>Draws an HTML string in the specified rectangle with the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a> and <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.font">Font</a> objects,
starting at a given offset within the string.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public int DrawToGraphics(Graphics g, RectangleF bounds, int offset)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function DrawToGraphics(g As Graphics, bounds As RectangleF, offset As Integer) As Integer</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.graphics">Graphics</a></td>
      <td><span class="parametername">g</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.graphics">Graphics</a> object where the content will be rendered.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectanglef">RectangleF</a></td>
      <td><span class="parametername">bounds</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a> that specifies the bounds where the content will be rendered.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">offset</span></td>
      <td><p>Offset of the first line to draw (usually the return value of a previous call to <b>DrawStringHtml</b>).</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><p>The offset of the first line that was not printed because it did not fit in the specified rectangle, or the value of
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32.maxvalue">MaxValue</a> if the entire string was rendered. By default zero.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
