I decided to try out another helper type of component next and this time it was the Spell component.To be honest, I didn’t expect to be much impressed with C1Spell as I had found in the past that wiring my apps up to the spell-check features in MS Office was the answer to my basic needs in this area.
But the key word in that last sentence is “basic”.The methods and facilities available in this component go way beyond what the average developer will achieve by simply wiring up to the standard MS Office Spellcheck.If you need detailed control of the spellcheck processes and user interaction then C1Spell will be your tool of choice.
The Spellchecker can be configured to check as the user types or can be run on a previously designated event, such as a button click or a when a control loses focus.
The following screenshot demonstrates three of the ways you can utilise this package:
You can use the dictionary that comes with the package or replace it with one of your own.I tried out the MS Office user dictionary from my own PC and it worked perfectly.
I was interested to read that ComponentOne offer a utility app to make it easy to create your own custom dictionaries from scratch (something I had had to wrestle with via MS Office in a VB.NET application a while ago).However I couldn’t find it initially, but once again a quick query to the Help Centre and the answer was supplied.(It’s accessed via the Start-Program menu in Windows, not in Visual Studio itself)
There are many other features, apart from the obvious core function of checking for incorrect spelling.To give you an idea of the depth of control on offer, here’s the CaretPosX Property
Returns the horizontal position of the caret on the edit window linked to the C1Spell component.
Public ReadOnly Property CaretPosX As Long
And if – like me – you began by wondering why you would ever want to know the value of this particular property, the help documentation gives us an example:
The caret position is returned in screen coordinates and expressed in twips.
This property is useful if you want to position user-interface elements such as pop-up menus or forms next to an offending word while spell checking. For example, to display a pop-up menu with a list of words, you would write code such as:
Dim pos As Point
Dim x, y
x = C1Spell1.CaretPosX
y = C1Spell1.CaretPosY
pos = New Point(x, y)
pos = TextBox1.PointToClient(Me.mPopup.Show(TextBox1, pos)
The C1Spell component also includes a Thesaurus facility.I didn’t test this in depth but did enough to confirm that it functions as you would expect.
All in all, a surprisingly useful utility component.