How to activate spellCheck in a Windows Form Forms application?

I am making a C # application for Windows Form in Visual Studio 2012. I want to add a text box with spell checking capabilities. Could you explain me the process for this?

+8
source share
4 answers

If you use .net4, you can add System.Xaml and WindowsFormsIntegration Links to the Winforms project.

This allows you to find the ElementHost in the toolbar. Using ElementHost, you can use WPF objects in a Winfroms project.

System.Windows.Forms.Integration.ElementHost elementHost1 = new System.Windows.Forms.Integration.ElementHost(); System.Windows.Controls.TextBox textBox = new System.Windows.Controls.TextBox(); textBox.SpellCheck.IsEnabled = true; elementHost1.Child = textBox; 
+10
source

There is no built-in spellcheck in the Windows Forms text box.

The best you can do is probably embed the WPF text box in your form. Hans Passant gives a very detailed answer in this post on how to achieve this.

+5
source

There is no WinForms option for this. But if you want to reuse it as a text field, create a UserFontrol WPF and place the WPF text block there. enable spell checking. If you drag an item node once, it will automatically add the necessary links, after which you can see your custom controls in the toolbar. as soon as user control is visible, all you have to do is drag it, it will automatically create an element host for you and put wpf user control in it.

+1
source

Basically, you just need to set the SpellCheck.IsEnabled property to true. Like this:

 TextBox textBox = new TextBox(); textBox.SpellCheck.IsEnabled = true; 

You can find this property in the System.Windows.Controls and refer to it as follows:

 using System.Windows.Controls; 

Editorial: I would strongly suggest using WPF over Winforms if this is an option you can explore. Winforms had its day once, but for a more modern development, WPF is a much more powerful platform.

-1
source

Source: https://habr.com/ru/post/969768/


All Articles