In this post I will show you the new Highlighter component that will be included in DotNetBar for Windows Forms 8.1 that we are planning on releasing soon.

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:

Figure 1 – Highlighter Components in VS.NET toolbox

This is how form looks like with Highlighter component added:

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:

Figure 3 – Setting HighlightColor property

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

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:

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

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

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

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)

I hope that this provides you with the good overview of the new Highlighter component that is unique to DotNetBar. I am sure in couple of months you will see clones everywhere, like it usually happens with new stuff we create 🙂