none
Spellcheck for text box

    Question

  • I am using VS2015 with .Net framework 4.6 and vb.net. I want to add a spellcheck to one of the text boxes in my project. I have done some research and found that there is a spellcheck class under the System.Windows.Controls namespace. I have added that namespace as a reference in my project (showed as System.Windows.Controls.Ribbon). Then I added an import command at the top of the window forms code (See below). But I am still unable to see that option when I try to set the spellcheck for my text box to true. What am I missing?

    Thanks.

    Imports System.Windows.Controls

    Monday, January 30, 2017 9:37 PM

All replies

  • Monday, January 30, 2017 10:47 PM
  • Hi J-Bal,

    Try the code, it works fine in my WPF project.

    XAML:

    <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
      <StackPanel>
        <TextBox SpellCheck.IsEnabled="True" Name="myTextBox"></TextBox>
      </StackPanel>
    
    </Page>

    VB code behind:

    Imports System
    Imports System.Windows
    Imports System.Windows.Controls
    
    Namespace SDKSample
    	Partial Public Class SpellCheckExample
    		Inherits Page
    		Public Sub New()
    			Dim myStackPanel As New StackPanel()
    
    			'Create TextBox
    			Dim myTextBox As New TextBox()
    			myTextBox.Width = 200
    
    			' Enable spellchecking on the TextBox.
    			myTextBox.SpellCheck.IsEnabled = True
    
    			' Alternatively, the SetIsEnabled method could be used
    			' to enable or disable spell checking like this:
    			' SpellCheck.SetIsEnabled(myTextBox, True)
    
    			myStackPanel.Children.Add(myTextBox)
    			Me.Content = myStackPanel
    		End Sub
    	End Class
    End Namespace

    Please give it a try in your side.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 01, 2017 5:19 AM