# C1.Win.Drawing.StringRendererGDIPlus.HighlightSubstring

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_Drawing_StringRendererGDIPlus_HighlightSubstring_" data-uid="C1.Win.Drawing.StringRendererGDIPlus.HighlightSubstring*">HighlightSubstring Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_Drawing_StringRendererGDIPlus_HighlightSubstring_" data-uid="C1.Win.Drawing.StringRendererGDIPlus.HighlightSubstring*"></a>
<h4 id="C1_Win_Drawing_StringRendererGDIPlus_HighlightSubstring_System_Drawing_Graphics_System_Drawing_Font_System_Drawing_StringFormat_System_Drawing_Brush_System_Drawing_Rectangle_System_String_System_Drawing_Brush_System_String_System_Int32_" data-uid="C1.Win.Drawing.StringRendererGDIPlus.HighlightSubstring(System.Drawing.Graphics,System.Drawing.Font,System.Drawing.StringFormat,System.Drawing.Brush,System.Drawing.Rectangle,System.String,System.Drawing.Brush,System.String,System.Int32)">HighlightSubstring(Graphics, Font, StringFormat, Brush, Rectangle, string, Brush, string, int)</h4>
<div class="markdown level1 summary"><p>Draws text and highlight a part of that text with a special background.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static void HighlightSubstring(Graphics graphics, Font font, StringFormat stringFormat, Brush foreBrush, Rectangle bounds, string text, Brush highlightBrush, string substring, int substringStartIndex)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Sub HighlightSubstring(graphics As Graphics, font As Font, stringFormat As StringFormat, foreBrush As Brush, bounds As Rectangle, text As String, highlightBrush As Brush, substring As String, substringStartIndex 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">graphics</span></td>
      <td><p>The device context in which to draw the text.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.font">Font</a></td>
      <td><span class="parametername">font</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.font">Font</a> to apply to the drawn text.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.stringformat">StringFormat</a></td>
      <td><span class="parametername">stringFormat</span></td>
      <td><p>The text layout information.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a></td>
      <td><span class="parametername">foreBrush</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a> to apply to the drawn text.</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>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a> that represents the bounds of the text.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>The text to draw.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a></td>
      <td><span class="parametername">highlightBrush</span></td>
      <td><p>The highlight <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a> of substrings.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">substring</span></td>
      <td><p>The substring to highlight.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">substringStartIndex</span></td>
      <td><p>The position at which the substring starts.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_Drawing_StringRendererGDIPlus_HighlightSubstring_" data-uid="C1.Win.Drawing.StringRendererGDIPlus.HighlightSubstring*"></a>
<h4 id="C1_Win_Drawing_StringRendererGDIPlus_HighlightSubstring_System_Drawing_Graphics_System_Drawing_Font_System_Drawing_StringFormat_System_Drawing_Brush_System_Drawing_Rectangle_System_String_System_Drawing_Brush_System_Collections_Generic_IList_System_Drawing_CharacterRange__" data-uid="C1.Win.Drawing.StringRendererGDIPlus.HighlightSubstring(System.Drawing.Graphics,System.Drawing.Font,System.Drawing.StringFormat,System.Drawing.Brush,System.Drawing.Rectangle,System.String,System.Drawing.Brush,System.Collections.Generic.IList{System.Drawing.CharacterRange})">HighlightSubstring(Graphics, Font, StringFormat, Brush, Rectangle, string, Brush, IList&lt;CharacterRange&gt;)</h4>
<div class="markdown level1 summary"><p>Draws text and highlight a parts of that text with a special background.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static void HighlightSubstring(Graphics graphics, Font font, StringFormat stringFormat, Brush foreBrush, Rectangle bounds, string text, Brush highlightBrush, IList&lt;CharacterRange&gt; substringRanges)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Sub HighlightSubstring(graphics As Graphics, font As Font, stringFormat As StringFormat, foreBrush As Brush, bounds As Rectangle, text As String, highlightBrush As Brush, substringRanges As IList(Of CharacterRange))</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">graphics</span></td>
      <td><p>The device context in which to draw the text.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.font">Font</a></td>
      <td><span class="parametername">font</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.font">Font</a> to apply to the drawn text.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.stringformat">StringFormat</a></td>
      <td><span class="parametername">stringFormat</span></td>
      <td><p>The text layout information.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a></td>
      <td><span class="parametername">foreBrush</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a> to apply to the drawn text.</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>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.rectangle">Rectangle</a> that represents the bounds of the text.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>The text to draw.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a></td>
      <td><span class="parametername">highlightBrush</span></td>
      <td><p>The highlight <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.brush">Brush</a> of substrings.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1">IList</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.characterrange">CharacterRange</a>&gt;</td>
      <td><span class="parametername">substringRanges</span></td>
      <td><p>Positions and lengths of all occurrences of substrings to highlight.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
