# Other Controls

> Spell check a Label or any WPF control with Check, the spell check dialog and IncorrectWordChanging, plus GetMenuItems menus and TXSpell without a control.

- **Product:** TX Spell .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Spell .NET for WPF > Integration Guide > Other Controls
- **1391 words**
- **Web URL:** https://docs.textcontrol.com/tx-spell-dotnet-wpf/integration/other-controls/
- **LLMs URL:** https://docs.textcontrol.com/tx-spell-dotnet-wpf/integration/other-controls/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-spell-dotnet-wpf/integration/other-controls/llms-full.txt

---

Every control that displays text can be spell checked with TX Spell .NET, not only TX Text Control and the `RichTextBox`. A grid cell, a label, a list item or the editor of another vendor: if your code can read the text and write it back, the spell checker finds the mistakes, offers suggestions and walks the user through them in its dialog. What your code has to do is the part TX Text Control would otherwise do: pass the text, and apply the corrections.

### The Pattern

Any control other than TX Text Control works like the `RichTextBox`: your code initializes the spell checker with [Create](https://docs.textcontrol.com/tx-spell-dotnet-wpf/reference/txtextcontrol-wpf-proofing/txspellchecker/create-method/llms-full.txt), passes the text to [Check](https://docs.textcontrol.com/tx-spell-dotnet-wpf/reference/txtextcontrol-wpf-proofing/txspellchecker/check-method/llms-full.txt), shows the incorrect words to the user and applies each correction in the [IncorrectWordChanging](https://docs.textcontrol.com/tx-spell-dotnet-wpf/reference/txtextcontrol-wpf-proofing/txspellchecker/incorrectwordchanging-event/llms-full.txt) event. [What TX Spell .NET Does and What Your Code Does](https://docs.textcontrol.com/tx-spell-dotnet-wpf/integration/richtextbox/#what-tx-spell-net-does-and-what-your-code-does) lists the parts.

### Check Any Control in the Dialog

This helper checks the text of any control in the spell check dialog. It takes two functions: one that reads the text of the control, and one that writes it back. The handler of `IncorrectWordChanging` applies each correction through them:

```csharp
// Reads and writes the text of the control being checked
private Func<string> getText;
private Action<string> setText;

private void CheckInDialog(Func<string> get, Action<string> set)
{
    getText = get;
    setText = set;

    txSpellChecker1.Check(getText());
    txSpellChecker1.SpellCheckDialog.Show(this);
}

private void txSpellChecker1_IncorrectWordChanging(object sender, IncorrectWordChangingEventArgs e)
{
    string text = getText();
    int start = e.IncorrectWord.Start;
    int length = e.IncorrectWord.Length;

    if (e.Type == TXSpell.ChangeType.Replace)
    {
        setText(text.Remove(start, length).Insert(start, e.CorrectedWord));
    }
    else if (e.Type == TXSpell.ChangeType.Delete)
    {
        setText(text.Remove(start, length));
    }
}
```

To check the content of a `Label`, call the helper with its text:

```csharp
CheckInDialog(
    () => Convert.ToString(label1.Content),
    value => label1.Content = value);
```

In the constructor of the window, get the spell checker with `FindResource`, call its [Create](https://docs.textcontrol.com/tx-spell-dotnet-wpf/reference/txtextcontrol-wpf-proofing/txspellchecker/create-method/llms-full.txt) method and attach the handler: `txSpellChecker1.IncorrectWordChanging += txSpellChecker1_IncorrectWordChanging;`.

The handler is the one of [Check a TextBox in the Dialog](https://docs.textcontrol.com/tx-spell-dotnet-wpf/spell-checking/on-demand/#check-a-textbox-in-the-dialog), which explains its arguments, with the text read and written through the two functions instead of a `TextBox`. To check several controls in one dialog, hand the dialog the next text in its closing event, as [Checking Multiple Controls](https://docs.textcontrol.com/tx-spell-dotnet-wpf/spell-checking/multiple-controls/llms-full.txt) shows.

### Offer Suggestions in a Context Menu

[GetMenuItems](https://docs.textcontrol.com/tx-spell-dotnet-wpf/reference/txtextcontrol-wpf-proofing/txspellchecker/getmenuitems-method/llms-full.txt) has an overload for any text: it takes an `IncorrectWord`, the text it was found in and the maximum number of suggestions, and returns ready-made menu items with the suggestions and the commands of the dialog. Add them to the context menu of your control; [Context Menus](https://docs.textcontrol.com/tx-spell-dotnet-wpf/user-interface/context-menus/llms-full.txt) builds such a menu for a `RichTextBox`, and the same code works for other controls.

### Code Without a Control

When there is no control at all, as in a service or a web application, the [TXSpell](https://docs.textcontrol.com/tx-spell-dotnet-wpf/reference/txtextcontrol-proofing/txspell/llms-full.txt) class checks text with the same `Check` and `CreateSuggestions` methods; see [Checking Text in Code](https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/in-code/llms-full.txt). For the Document Editor of TX Text Control .NET Server, see [TX Text Control .NET Server Document Editor](https://docs.textcontrol.com/tx-spell-dotnet-wpf/integration/document-editor/llms-full.txt).

### Next Steps

- [RichTextBox](https://docs.textcontrol.com/tx-spell-dotnet-wpf/integration/richtextbox/llms-full.txt): the pattern applied to the standard controls.
- [Events](https://docs.textcontrol.com/tx-spell-dotnet-wpf/spell-checking/events/llms-full.txt): everything the arguments of `IncorrectWordChanging` carry.
- [Spell Check Dialog](https://docs.textcontrol.com/tx-spell-dotnet-wpf/user-interface/spell-check-dialog/llms-full.txt): the dialog your users work with.

---

## Nearby

- **Previous:** [RichTextBox](https://docs.textcontrol.com/tx-spell-dotnet-wpf/integration/richtextbox/llms-full.txt)
- **Next:** [TX Text Control .NET Server Document Editor](https://docs.textcontrol.com/tx-spell-dotnet-wpf/integration/document-editor/llms-full.txt)
