文本框的拼写检查 [英] Spellcheck for text box

查看:64
本文介绍了文本框的拼写检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将VS2015与.Net Framework 4.6和vb.net一起使用.我想将拼写检查添加到项目中的一个文本框中.我进行了一些研究,发现在System.Windows.Controls命名空间下有一个拼写检查类.我已经添加了 该命名空间作为我项目中的引用(显示为System.Windows.Controls.Ribbon).然后,我在窗口表单代码的顶部添加了一个导入命令(请参见下文).但是当我尝试为文本框设置拼写检查时,我仍然看不到该选项 真实.我想念什么?

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?

谢谢.

导入System.Windows.Controls

Imports System.Windows.Controls

推荐答案

J-Bal,

尝试代码,在我的WPF项目中可以正常工作.

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代码:

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

请尝试一下.

最诚挚的问候

抓取


这篇关于文本框的拼写检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆