Results 1 to 6 of 6

Thread: Rich Text Box Spell Check

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Rich Text Box Spell Check

    hi

    got the following code from microsoft online thing...

    Code:
    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
    however, i'm getting the error "Namespace' statements can occur only at file or namespace level."

    not sure what im doing wrong...can't work out where the namespace statement should be placed...thanks in advance

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Rich Text Box Spell Check

    Where have you put that code? Is it on its own in its own code file or did you paste into some existing code?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Rich Text Box Spell Check

    By the way, that code is for WPF, not Windows Forms. Are you using WPF?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Re: Rich Text Box Spell Check

    Aw man! I'm using vb. I'm sure I got that on the vb section of Microsoft online.

    Trying to get the red underline on misspelt words in my rich text box...any advice?

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Rich Text Box Spell Check

    Sure, I have some advice: answer the questions I asked.

    I didn't say that that wasn't VB code. It is VB code. What I said was that it is for WPF rather than Windows Forms. VB is a programming language. WPF and Windows Forms are technologies. When you created your VB project, you'd have selected a project type. If you chose Windows Forms Application then that code is useless to you. If you chose WPF Application then that code is applicable.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Re: Rich Text Box Spell Check

    Sorry, quite new to this - just learning, I hope that's ok.

    So, it's a windows form application I'm creating.

    I had pasted that code under public class, with the three "imports" lines before the public class - although this info may be irrelevant now seeing as this code won't work with windows forms :S
    Thanks for your help, I appreciate it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width