Highlighter component allows you to visually highlight any control on the form using distinctive border style. You can use it with our SuperValidator component to highlight validation errors on the form. You can use it to highlight currently focused text-box. Or simply to draw user attention to control on the form.

To start using Highlighter control just double-click the highlighter component in VS.NET Toolbox to add it to the form:

Highlighter WinForms Control

Figure 1 – Highlighter Components in VS.NET toolbox

This is how form looks like with Highlighter component added:

Highlighter Control on the form

Figure 2 – Highlighter Component on the form

To each control on the form the Highlighter component will add two properties:

  • HighlightColor – Specifies the color to highlight the control with.
  • HighlightOnFocus – Specifies whether control is automatically highlighted when it receives input focus. Highlighter.FocusHighlightColor property specifies the color that will be used for focus based highlighting.

To highlight any control on the form select the control and set HighlightColor property:

Highlighter3

Figure 3 – Setting HighlightColor property

This is how control would appear at run-time with HighlightColor property set:

Highlighter4

Figure 4 – Highlighter component highlighting the control

Setting HighlightColor from code

To set HighlightColor using code, use following statement:

highlighter1.SetHighlightColor(textBoxX1, eHighlightColor.Green)

To remove highlight from the control use following statement:

highlighter1.SetHighlightColor(textBoxX1, eHighlightColor.None)

Highlighting Focused Control

Highlighter component provides you with functionality to highlight control with the input focus automatically. All you have to do is set HighlightOnFocus property on each control on the form that you want to highlight. The easiest way to do that is to select all controls on the form you want to highlight as they receive focus:

Highlighter5

Figure 5 – Select all controls you want to highlight on focus

Then in VS.NET property window set HighlightOnFocus property to true:

Highlighter6

Now when you run your project and tab through controls on the form you will see the focused control highlighted:

HighlighterFocusAnimation

To create focus highlighting from code use following statement:

highlighter1.SetHighlightOnFocus(textBoxX1, True)

and to remove focus highlight use following statement:

highlighter1.SetHighlightOnFocus(Me.textBoxX1, False)

Related posts:

  1. SuperValidator for Windows Forms, All you need to know
  2. How to create SuperTooltip using code
  3. How to create Ribbon Tab Groups in DotNetBar for WinForms
  4. How to Create Context Menus
  5. Everything about LayoutControl in DotNetBar for WinForms