Link to home
Start Free TrialLog in
Avatar of TheUndecider
TheUndeciderFlag for United States of America

asked on

.NET 2008 and NetSpell leaves Spelling windows opened

Hello,

I am using Visual Studio 2008 and NetSpell to check for spelling.  This way to check for spelling is way faster than using the spellcheck from Word.
 
I got a sample from another question here on EE.  I am using the F7 key as my spelling keystroke to launch the NetSpell screen.

I use it in a form that contains a text field called txtComments.  The content of this field will become a record once I click on my Add button that also exists on this form.

My problem is that after hitting F7 for the Netspell screen to show up and I then click  the Add button in my form, the record gets added and the NetSpell screen doesn't close.  If I enter more comments and hit F7 again, I end up with 2 NetSpell screens and so on.

I need to check that all instances of the Netspell pop up windows are properly disposed, or make this netspell the top most so the user cannot do anything until they close it.

Any ideas?



this is the code I got:



    Private Sub Spelling_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtComments.KeyDown

        'activate the spell check with the F7 function.
        If e.KeyCode = Keys.F7 Then
            'Calling code from form
            Dim spClass As New clSpellCheck

            Try
                'check spelling in text box
                If Me.txtComments.Text = Nothing Then
                    MessageBox.Show("No text to spell check!")
                    Exit Sub
                Else
                    spClass.SpellMe(Me.txtComments)
                    Dim chars As Char() = {CType(vbCr, Char), CType(vbLf, Char)}
                    Me.txtComments.Text = Me.txtComments.Text.Trim(chars)
                End If
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End If
         
    End Sub



This is my class.

'Class containing NetSpell
Public Class clSpellCheck
    Private WithEvents SpellChecker As New NetSpell.SpellChecker.Spelling
    Private myTB As TextBox

    Public Sub SpellMe(ByVal tb As TextBox)
        myTB = tb
        SpellChecker.Text = myTB.Text
        SpellChecker.SpellCheck()
    End Sub

    Private Sub SpellChecker_DoubledWord(ByVal sender As Object, ByVal args As NetSpell.SpellChecker.SpellingEventArgs) Handles SpellChecker.DoubledWord
        ' update text
        myTB.Text = SpellChecker.Text
    End Sub

    Private Sub SpellChecker_EndOfText(ByVal sender As Object, ByVal e As System.EventArgs) Handles SpellChecker.EndOfText
        ' update text
        myTB.Text = SpellChecker.Text
    End Sub

    Private Sub SpellChecker_MisspelledWord(ByVal sender As Object, ByVal args As NetSpell.SpellChecker.SpellingEventArgs) Handles SpellChecker.MisspelledWord
        ' update text
        myTB.Text = SpellChecker.Text
    End Sub

End Class

Thanks.
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Do you have code for this method?

SpellChecker.SpellCheck()
Avatar of TheUndecider

ASKER

Hello,

No, I do not.  That comes directly from the dll fiile.  I downloaded NetSpell from here


http://sourceforge.net/projects/netspell/files/NetSpell/NetSpell%202.1.7/NetSpell.Setup.msi/download

The whole thing is encoded using C+ though.
This is from the spelling.cs file from that project.
// Copyright (c) 2003, Paul Welter
// All rights reserved.

using System;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Forms.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;

using NetSpell.SpellChecker.Forms;
using NetSpell.SpellChecker.Dictionary;
using NetSpell.SpellChecker.Dictionary.Affix;
using NetSpell.SpellChecker.Dictionary.Phonetic;


namespace NetSpell.SpellChecker
{
	/// <summary>
	///		The Spelling class encapsulates the functions necessary to check
	///		the spelling of inputted text.
	/// </summary>
	[ToolboxBitmap(typeof(NetSpell.SpellChecker.Spelling), "Spelling.bmp")]
	public class Spelling : System.ComponentModel.Component
	{

		#region Global Regex
		// Regex are class scope and compiled to improve performance on reuse
		private Regex _digitRegex = new Regex(@"^\d", RegexOptions.Compiled);
		private Regex _htmlRegex = new Regex(@"</[c-g\d]+>|</[i-o\d]+>|</[a\d]+>|</[q-z\d]+>|<[cg]+[^>]*>|<[i-o]+[^>]*>|<[q-z]+[^>]*>|<[a]+[^>]*>|<(\[^\]*\|'[^']*'|[^'\>])*>", RegexOptions.IgnoreCase & RegexOptions.Compiled);
		private MatchCollection _htmlTags;
		private Regex _letterRegex = new Regex(@"\D", RegexOptions.Compiled);
		private Regex _upperRegex = new Regex(@"[^A-Z]", RegexOptions.Compiled);
		private Regex _wordEx = new Regex(@"\b[A-Za-z0-9_'À-ÿ]+\b", RegexOptions.Compiled);
		private MatchCollection _words;
		#endregion

		#region private variables
		private System.ComponentModel.Container components = null;
		#endregion

		#region Events

		/// <summary>
		///     This event is fired when a word is deleted
		/// </summary>
		/// <remarks>
		///		Use this event to update the parent text
		/// </remarks>
		public event DeletedWordEventHandler DeletedWord;

		/// <summary>
		///     This event is fired when word is detected two times in a row
		/// </summary>
		public event DoubledWordEventHandler DoubledWord;

		/// <summary>
		///     This event is fired when the spell checker reaches the end of
		///     the text in the Text property
		/// </summary>
		public event EndOfTextEventHandler EndOfText;

		/// <summary>
		///     This event is fired when a word is skipped
		/// </summary>
		public event IgnoredWordEventHandler IgnoredWord;

		/// <summary>
		///     This event is fired when the spell checker finds a word that 
		///     is not in the dictionaries
		/// </summary>
		public event MisspelledWordEventHandler MisspelledWord;

		/// <summary>
		///     This event is fired when a word is replace
		/// </summary>
		/// <remarks>
		///		Use this event to update the parent text
		/// </remarks>
		public event ReplacedWordEventHandler ReplacedWord;


		/// <summary>
		///     This represents the delegate method prototype that
		///     event receivers must implement
		/// </summary>
		public delegate void DeletedWordEventHandler(object sender, SpellingEventArgs e);

		/// <summary>
		///     This represents the delegate method prototype that
		///     event receivers must implement
		/// </summary>
		public delegate void DoubledWordEventHandler(object sender, SpellingEventArgs e);

		/// <summary>
		///     This represents the delegate method prototype that
		///     event receivers must implement
		/// </summary>
		public delegate void EndOfTextEventHandler(object sender, System.EventArgs e);

		/// <summary>
		///     This represents the delegate method prototype that
		///     event receivers must implement
		/// </summary>
		public delegate void IgnoredWordEventHandler(object sender, SpellingEventArgs e);

		/// <summary>
		///     This represents the delegate method prototype that
		///     event receivers must implement
		/// </summary>
		public delegate void MisspelledWordEventHandler(object sender, SpellingEventArgs e);

		/// <summary>
		///     This represents the delegate method prototype that
		///     event receivers must implement
		/// </summary>
		public delegate void ReplacedWordEventHandler(object sender, ReplaceWordEventArgs e);

		/// <summary>
		///     This is the method that is responsible for notifying
		///     receivers that the event occurred
		/// </summary>
		protected virtual void OnDeletedWord(SpellingEventArgs e)
		{
			if (DeletedWord != null)
			{
				DeletedWord(this, e);
			}
		}

		/// <summary>
		///     This is the method that is responsible for notifying
		///     receivers that the event occurred
		/// </summary>
		protected virtual void OnDoubledWord(SpellingEventArgs e)
		{
			if (DoubledWord != null)
			{
				DoubledWord(this, e);
			}
		}

		/// <summary>
		///     This is the method that is responsible for notifying
		///     receivers that the event occurred
		/// </summary>
		protected virtual void OnEndOfText(System.EventArgs e)
		{
			if (EndOfText != null)
			{
				EndOfText(this, e);
			}
		}

		/// <summary>
		///     This is the method that is responsible for notifying
		///     receivers that the event occurred
		/// </summary>
		protected virtual void OnIgnoredWord(SpellingEventArgs e)
		{
			if (IgnoredWord != null)
			{
				IgnoredWord(this, e);
			}
		}

		/// <summary>
		///     This is the method that is responsible for notifying
		///     receivers that the event occurred
		/// </summary>
		protected virtual void OnMisspelledWord(SpellingEventArgs e)
		{
			if (MisspelledWord != null)
			{
				MisspelledWord(this, e);
			}
		}

		/// <summary>
		///     This is the method that is responsible for notifying
		///     receivers that the event occurred
		/// </summary>
		protected virtual void OnReplacedWord(ReplaceWordEventArgs e)
		{
			if (ReplacedWord != null)
			{
				ReplacedWord(this, e);
			}
		}

		#endregion

		#region Constructors
		/// <summary>
		///     Initializes a new instance of the SpellCheck class
		/// </summary>
		public Spelling()
		{
			InitializeComponent();
		}


		/// <summary>
		///     Required for Windows.Forms Class Composition Designer support
		/// </summary>
		public Spelling(System.ComponentModel.IContainer container)
		{
			container.Add(this);
			InitializeComponent();
		}

		#endregion

		#region private methods

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
					components.Dispose();
				
				// free form resources
				if(_suggestionForm != null)
					_suggestionForm.Dispose();
			}
			base.Dispose( disposing );
		}

		/// <summary>
		///     Calculates the words from the Text property
		/// </summary>
		private void CalculateWords()
		{
			// splits the text into words
			_words = _wordEx.Matches(_text.ToString());
			
			// remark html
			this.MarkHtml();
		}

		/// <summary>
		///     Determines if the string should be spell checked
		/// </summary>
		/// <param name="characters" type="string">
		///     <para>
		///         The Characters to check
		///     </para>
		/// </param>
		/// <returns>
		///     Returns true if the string should be spell checked
		/// </returns>
		private bool CheckString(string characters)
		{
			if(_ignoreAllCapsWords && !_upperRegex.IsMatch(characters))
			{
				return false;
			}
			if(_ignoreWordsWithDigits && _digitRegex.IsMatch(characters))
			{
				return false;
			}
			if(!_letterRegex.IsMatch(characters))
			{
				return false;
			}
			if(_ignoreHtml)
			{
				int startIndex = _words[this.WordIndex].Index;
				
				foreach (Match item in _htmlTags) 
				{
					if (startIndex >= item.Index && startIndex <= item.Index + item.Length - 1)
					{
						return false;
					}
				}
			}
			return true;
		}

		private void Initialize()
		{
			if(_dictionary == null)
				_dictionary = new WordDictionary();

			if(!_dictionary.Initialized)
				_dictionary.Initialize();

			if(_suggestionForm == null && _showDialog)
				_suggestionForm = new SuggestionForm(this);
		}
		/// <summary>
		///     Calculates the position of html tags in the Text property
		/// </summary>
		private void MarkHtml()
		{
			// splits the text into words
			_htmlTags = _htmlRegex.Matches(_text.ToString());
		}

		/// <summary>
		///     Resets the public properties
		/// </summary>
		private void Reset()
		{
			_wordIndex = 0; // reset word index
			_replacementWord = "";
			_suggestions.Clear();
		}

		#endregion

		#region ISpell Near Miss Suggetion methods

		/// <summary>
		///		swap out each char one by one and try all the tryme
		///		chars in its place to see if that makes a good word
		/// </summary>
		private void BadChar(ref ArrayList tempSuggestion)
		{
			for (int i = 0; i < this.CurrentWord.Length; i++)
			{
				StringBuilder tempWord = new StringBuilder(this.CurrentWord);
				char[] tryme = this.Dictionary.TryCharacters.ToCharArray();
				for (int x = 0; x < tryme.Length; x++)
				{
					tempWord[i] = tryme[x];
					if (this.TestWord(tempWord.ToString())) 
					{
						Word ws = new Word();
						ws.Text = tempWord.ToString().ToLower();
						ws.EditDistance = this.EditDistance(this.CurrentWord, tempWord.ToString());
				
						tempSuggestion.Add(ws);
					}
				}			 
			}
		}

		/// <summary>
		///     try omitting one char of word at a time
		/// </summary>
		private void ExtraChar(ref ArrayList tempSuggestion)
		{
			if (this.CurrentWord.Length > 1) 
			{
				for (int i = 0; i < this.CurrentWord.Length; i++)
				{
					StringBuilder tempWord = new StringBuilder(this.CurrentWord);
					tempWord.Remove(i, 1);

					if (this.TestWord(tempWord.ToString())) 
					{
						Word ws = new Word();
						ws.Text = tempWord.ToString().ToLower(CultureInfo.CurrentUICulture);
						ws.EditDistance = this.EditDistance(this.CurrentWord, tempWord.ToString());
				
						tempSuggestion.Add(ws);
					}
								 
				}
			}
		}

		/// <summary>
		///     try inserting a tryme character before every letter
		/// </summary>
		private void ForgotChar(ref ArrayList tempSuggestion)
		{
			char[] tryme = this.Dictionary.TryCharacters.ToCharArray();
				
			for (int i = 0; i <= this.CurrentWord.Length; i++)
			{
				for (int x = 0; x < tryme.Length; x++)
				{
					StringBuilder tempWord = new StringBuilder(this.CurrentWord);
				
					tempWord.Insert(i, tryme[x]);
					if (this.TestWord(tempWord.ToString())) 
					{
						Word ws = new Word();
						ws.Text = tempWord.ToString().ToLower();
						ws.EditDistance = this.EditDistance(this.CurrentWord, tempWord.ToString());
				
						tempSuggestion.Add(ws);
					}
				}			 
			}
		}

		/// <summary>
		///     suggestions for a typical fault of spelling, that
		///		differs with more, than 1 letter from the right form.
		/// </summary>
		private void ReplaceChars(ref ArrayList tempSuggestion)
		{
			ArrayList replacementChars = this.Dictionary.ReplaceCharacters;
			for (int i = 0; i < replacementChars.Count; i++)
			{
				int split = ((string)replacementChars[i]).IndexOf(' ');
				string key = ((string)replacementChars[i]).Substring(0, split);
				string replacement = ((string)replacementChars[i]).Substring(split+1);

				int pos = this.CurrentWord.IndexOf(key);
				while (pos > -1)
				{
					string tempWord = this.CurrentWord.Substring(0, pos);
					tempWord += replacement;
					tempWord += this.CurrentWord.Substring(pos + key.Length);

					if (this.TestWord(tempWord))
					{
						Word ws = new Word();
						ws.Text = tempWord.ToString().ToLower();
						ws.EditDistance = this.EditDistance(this.CurrentWord, tempWord.ToString());
				
						tempSuggestion.Add(ws);
					}
					pos = this.CurrentWord.IndexOf(key, pos+1);
				}
			}
		}

		/// <summary>
		///     try swapping adjacent chars one by one
		/// </summary>
		private void SwapChar(ref ArrayList tempSuggestion)
		{
			for (int i = 0; i < this.CurrentWord.Length - 1; i++)
			{
				StringBuilder tempWord = new StringBuilder(this.CurrentWord);
				
				char swap = tempWord[i];
				tempWord[i] = tempWord[i+1];
				tempWord[i+1] = swap;

				if (this.TestWord(tempWord.ToString())) 
				{
					
					Word ws = new Word();
					ws.Text = tempWord.ToString().ToLower();
					ws.EditDistance = this.EditDistance(this.CurrentWord, tempWord.ToString());
				
					tempSuggestion.Add(ws);
				}	 
			}
		}
		
		/// <summary>
		///     split the string into two pieces after every char
		///		if both pieces are good words make them a suggestion
		/// </summary>
		private void TwoWords(ref ArrayList tempSuggestion)
		{
			for (int i = 1; i < this.CurrentWord.Length - 1; i++)
			{
				string firstWord = this.CurrentWord.Substring(0,i);
				string secondWord = this.CurrentWord.Substring(i);
				
				if (this.TestWord(firstWord) && this.TestWord(secondWord)) 
				{
					string tempWord = firstWord + " " + secondWord;
					
					Word ws = new Word();
					ws.Text = tempWord.ToString().ToLower();
					ws.EditDistance = this.EditDistance(this.CurrentWord, tempWord.ToString());
				
					tempSuggestion.Add(ws);
				}	 
			}
		}

		#endregion

		#region public methods

		/// <summary>
		///     Deletes the CurrentWord from the Text Property
		/// </summary>
		/// <remarks>
		///		Note, calling ReplaceWord with the ReplacementWord property set to 
		///		an empty string has the same behavior as DeleteWord.
		/// </remarks>
		public void DeleteWord()
		{
			if (_words == null || _words.Count == 0)
			{
				TraceWriter.TraceWarning("No Words to Delete");
				return;
			}
			string replacedWord = this.CurrentWord;
			int replacedIndex = this.WordIndex;

			int index = _words[replacedIndex].Index;
			int length = _words[replacedIndex].Length;
			
			// adjust length to remove extra white space after first word
			if (index == 0 
				&& index + length < _text.Length 
				&& _text[index+length] == ' ')
			{
				length++; //removing trailing space
			}
			// adjust length to remove double white space
			else if (index > 0 
				&& index + length < _text.Length 
				&& _text[index-1] == ' ' 
				&& _text[index+length] == ' ')
			{					
				length++; //removing trailing space
			}
			// adjust index to remove extra white space before punctuation
			else if (index > 0 
				&& index + length < _text.Length 
				&& _text[index-1] == ' ' 
				&& char.IsPunctuation(_text[index+length]))
			{					
				index--;
				length++;
			}
			// adjust index to remove extra white space before last word
			else if (index > 0 
				&& index + length == _text.Length
				&& _text[index-1] == ' ')	
			{				
				index--;
				length++;
			}

			string deletedWord = _text.ToString(index, length);
			_text.Remove(index, length);
			
			this.CalculateWords();
			this.OnDeletedWord(new SpellingEventArgs(deletedWord, replacedIndex, index));
		}

		/// <summary>
		///     Calculates the minimum number of change, inserts or deletes
		///     required to change firstWord into secondWord
		/// </summary>
		/// <param name="source" type="string">
		///     <para>
		///         The first word to calculate
		///     </para>
		/// </param>
		/// <param name="target" type="string">
		///     <para>
		///         The second word to calculate
		///     </para>
		/// </param>
		/// <param name="positionPriority" type="bool">
		///     <para>
		///         set to true if the first and last char should have priority
		///     </para>
		/// </param>
		/// <returns>
		///     The number of edits to make firstWord equal secondWord
		/// </returns>
		public int EditDistance(string source, string target, bool positionPriority)
		{
		
			// i.e. 2-D array
			Array matrix = Array.CreateInstance(typeof(int), source.Length+1, target.Length+1);

			// boundary conditions
			matrix.SetValue(0, 0, 0); 

			for(int j=1; j <= target.Length; j++)
			{
				// boundary conditions
				int val = (int)matrix.GetValue(0,j-1);
				matrix.SetValue(val+1, 0, j);
			}

			// outer loop
			for(int i=1; i <= source.Length; i++)                            
			{ 
				// boundary conditions
				int val = (int)matrix.GetValue(i-1, 0);
				matrix.SetValue(val+1, i, 0); 

				// inner loop
				for(int j=1; j <= target.Length; j++)                         
				{ 
					int diag = (int)matrix.GetValue(i-1, j-1);

					if(source.Substring(i-1, 1) != target.Substring(j-1, 1)) 
					{
						diag++;
					}

					int deletion = (int)matrix.GetValue(i-1, j);
					int insertion = (int)matrix.GetValue(i, j-1);
					int match = Math.Min(deletion+1, insertion+1);		
					matrix.SetValue(Math.Min(diag, match), i, j);
				}//for j
			}//for i

			int dist = (int)matrix.GetValue(source.Length, target.Length);

			// extra edit on first and last chars
			if (positionPriority)
			{
				if (source[0] != target[0]) dist++;
				if (source[source.Length-1] != target[target.Length-1]) dist++;
			}
			return dist;
		}
		
		/// <summary>
		///     Calculates the minimum number of change, inserts or deletes
		///     required to change firstWord into secondWord
		/// </summary>
		/// <param name="source" type="string">
		///     <para>
		///         The first word to calculate
		///     </para>
		/// </param>
		/// <param name="target" type="string">
		///     <para>
		///         The second word to calculate
		///     </para>
		/// </param>
		/// <returns>
		///     The number of edits to make firstWord equal secondWord
		/// </returns>
		/// <remarks>
		///		This method automatically gives priority to matching the first and last char
		/// </remarks>
		public int EditDistance(string source, string target)
		{
			return this.EditDistance(source, target, true);
		}

		/// <summary>
		///		Gets the word index from the text index.  Use this method to 
		///		find a word based on the text position.
		/// </summary>
		/// <param name="textIndex">
		///		<para>
		///         The index to search for
		///     </para>
		/// </param>
		/// <returns>
		///		The word index that the text index falls on
		/// </returns>
		public int GetWordIndexFromTextIndex(int textIndex)
		{
			if (_words == null || _words.Count == 0 || textIndex < 1)
			{
				TraceWriter.TraceWarning("No words to get text index from.");
				return 0;
			}

			if(_words.Count == 1)
				return 0;

			int low=0; 
			int high=_words.Count-1; 

			// binary search
			while(low<=high) 
			{ 
				int mid=(low+high)/2; 
				int wordStartIndex = _words[mid].Index;
				int wordEndIndex = _words[mid].Index + _words[mid].Length - 1;
			
				// add white space to end of word by finding the start of the next word
				if ((mid+1) < _words.Count)
					wordEndIndex = _words[mid+1].Index - 1;

				if(textIndex < wordStartIndex) 
					high=mid-1; 
				else if(textIndex > wordEndIndex) 
					low=mid+1; 
				else if(wordStartIndex <= textIndex && textIndex <= wordEndIndex) 
					return mid; 
			} 

			// return last word if not found
			return _words.Count-1;
		}

		/// <summary>
		///     Ignores all instances of the CurrentWord in the Text Property
		/// </summary>
		public void IgnoreAllWord()
		{
			if (this.CurrentWord.Length == 0)
			{
				TraceWriter.TraceWarning("No current word");
				return;
			}

			// Add current word to ignore list
			_ignoreList.Add(this.CurrentWord);
			this.IgnoreWord();
		}

		/// <summary>
		///     Ignores the instances of the CurrentWord in the Text Property
		/// </summary>
		/// <remarks>
		///		Must call SpellCheck after call this method to resume
		///		spell checking
		/// </remarks>
		public void IgnoreWord()
		{	
			
			if (_words == null || _words.Count == 0 || this.CurrentWord.Length == 0)
			{
				TraceWriter.TraceWarning("No text or current word");
				return;
			}

			this.OnIgnoredWord(new SpellingEventArgs(
				this.CurrentWord, 
				this.WordIndex, 
				_words[this.WordIndex].Index));

			// increment Word Index to skip over this word
			_wordIndex++;
		}

		/// <summary>
		///     Replaces all instances of the CurrentWord in the Text Property
		/// </summary>
		public void ReplaceAllWord()
		{
			if (this.CurrentWord.Length == 0)
			{
				TraceWriter.TraceWarning("No current word");
				return;
			}

			// if not in list and replacement word has length
			if(!_replaceList.ContainsKey(this.CurrentWord) && _replacementWord.Length > 0) 
			{
				_replaceList.Add(this.CurrentWord, _replacementWord);
			}
			
			this.ReplaceWord();
		}

		/// <summary>
		///     Replaces all instances of the CurrentWord in the Text Property
		/// </summary>
		/// <param name="replacementWord" type="string">
		///     <para>
		///         The word to replace the CurrentWord with
		///     </para>
		/// </param>
		public void ReplaceAllWord(string replacementWord)
		{
			this.ReplacementWord = replacementWord;
			this.ReplaceAllWord();
		}


		/// <summary>
		///     Replaces the instances of the CurrentWord in the Text Property
		/// </summary>
		public void ReplaceWord()
		{
			if (_words == null || _words.Count == 0 || this.CurrentWord.Length == 0)
			{
				TraceWriter.TraceWarning("No text or current word");
				return;
			}

			if (_replacementWord.Length == 0) 
			{
				this.DeleteWord();
				return;
			}
			string replacedWord = this.CurrentWord;
			int replacedIndex = this.WordIndex;

			int index = _words[replacedIndex].Index;
			int length = _words[replacedIndex].Length;
            
			_text.Remove(index, length);
			// if first letter upper case, match case for replacement word
			if (char.IsUpper(_words[replacedIndex].ToString(), 0))
			{
				_replacementWord = _replacementWord.Substring(0,1).ToUpper(CultureInfo.CurrentUICulture) 
					+ _replacementWord.Substring(1);
			}
			_text.Insert(index, _replacementWord);
			
			this.CalculateWords();

			this.OnReplacedWord(new ReplaceWordEventArgs(
				_replacementWord, 
				replacedWord, 
				replacedIndex, 
				index));
		}

		/// <summary>
		///     Replaces the instances of the CurrentWord in the Text Property
		/// </summary>
		/// <param name="replacementWord" type="string">
		///     <para>
		///         The word to replace the CurrentWord with
		///     </para>
		/// </param>
		public void ReplaceWord(string replacementWord)
		{
			this.ReplacementWord = replacementWord;
			this.ReplaceWord();
		}

		/// <summary>
		///     Spell checks the words in the <see cref="Text"/> property starting
		///     at the <see cref="WordIndex"/> position.
		/// </summary>
		/// <returns>
		///     Returns true if there is a word found in the text 
		///     that is not in the dictionaries
		/// </returns>
		/// <seealso cref="CurrentWord"/>
		/// <seealso cref="WordIndex"/>
		public bool SpellCheck()
		{
			return SpellCheck(_wordIndex, this.WordCount-1);
		}

		/// <summary>
		///     Spell checks the words in the <see cref="Text"/> property starting
		///     at the <see cref="WordIndex"/> position. This overload takes in the
		///     WordIndex to start checking from.
		/// </summary>
		/// <param name="startWordIndex" type="int">
		///     <para>
		///         The index of the word to start checking from. 
		///     </para>
		/// </param>
		/// <returns>
		///     Returns true if there is a word found in the text 
		///     that is not in the dictionaries
		/// </returns>
		/// <seealso cref="CurrentWord"/>
		/// <seealso cref="WordIndex"/>
		public bool SpellCheck(int startWordIndex)
		{
			_wordIndex = startWordIndex;
			return SpellCheck();
		}

		/// <summary>
		///     Spell checks a range of words in the <see cref="Text"/> property starting
		///     at the <see cref="WordIndex"/> position and ending at endWordIndex. 
		/// </summary>
		/// <param name="startWordIndex" type="int">
		///     <para>
		///         The index of the word to start checking from. 
		///     </para>
		/// </param>
		/// <param name="endWordIndex" type="int">
		///     <para>
		///         The index of the word to end checking with. 
		///     </para>
		/// </param>
		/// <returns>
		///     Returns true if there is a word found in the text 
		///     that is not in the dictionaries
		/// </returns>
		/// <seealso cref="CurrentWord"/>
		/// <seealso cref="WordIndex"/>
		public bool SpellCheck(int startWordIndex, int endWordIndex)
		{
			if(startWordIndex > endWordIndex || _words == null || _words.Count == 0) 
			{
				// make sure end index is not greater then word count
				this.OnEndOfText(System.EventArgs.Empty);	//raise event
				return false;
			}

			this.Initialize();

			string currentWord = "";
			bool misspelledWord = false;

			for (int i = startWordIndex; i <= endWordIndex; i++) 
			{
				_wordIndex = i;		// saving the current word index 
				currentWord = this.CurrentWord;

				if(CheckString(currentWord)) 
				{
					if(!TestWord(currentWord)) 
					{
						if(_replaceList.ContainsKey(currentWord)) 
						{
							this.ReplacementWord = _replaceList[currentWord].ToString();
							this.ReplaceWord();
						}
						else if(!_ignoreList.Contains(currentWord))
						{
							misspelledWord = true;
							this.OnMisspelledWord(new SpellingEventArgs(currentWord, i, _words[i].Index));		//raise event
							break;
						}
					}
					else if(i > 0 && _words[i-1].Value.ToString() == currentWord 
						&& (_words[i-1].Index + _words[i-1].Length + 1) == _words[i].Index)
					{
						misspelledWord = true;
						this.OnDoubledWord(new SpellingEventArgs(currentWord, i, _words[i].Index));		//raise event
						break;
					}
				}
			} // for

			if(_wordIndex >= _words.Count-1 && !misspelledWord) 
			{
				this.OnEndOfText(System.EventArgs.Empty);	//raise event
			}
		
			return misspelledWord;

		} // SpellCheck
		
		/// <summary>
		///     Spell checks the words in the <see cref="Text"/> property starting
		///     at the <see cref="WordIndex"/> position. This overload takes in the 
		///     text to spell check
		/// </summary>
		/// <param name="text" type="string">
		///     <para>
		///         The text to spell check
		///     </para>
		/// </param>
		/// <returns>
		///     Returns true if there is a word found in the text 
		///     that is not in the dictionaries
		/// </returns>
		/// <seealso cref="CurrentWord"/>
		/// <seealso cref="WordIndex"/>
		public bool SpellCheck(string text)
		{
			this.Text = text;
			return SpellCheck();
		}

		/// <summary>
		///     Spell checks the words in the <see cref="Text"/> property starting
		///     at the <see cref="WordIndex"/> position. This overload takes in 
		///     the text to check and the WordIndex to start checking from.
		/// </summary>
		/// <param name="text" type="string">
		///     <para>
		///         The text to spell check
		///     </para>
		/// </param>
		/// <param name="startWordIndex" type="int">
		///     <para>
		///         The index of the word to start checking from
		///     </para>
		/// </param>
		/// <returns>
		///     Returns true if there is a word found in the text 
		///     that is not in the dictionaries
		/// </returns>
		/// <seealso cref="CurrentWord"/>
		/// <seealso cref="WordIndex"/>
		public bool SpellCheck(string text, int startWordIndex)
		{
			this.WordIndex = startWordIndex;
			this.Text = text;
			return SpellCheck();
		}

		/// <summary>
		///     Populates the <see cref="Suggestions"/> property with word suggestions
		///     for the word
		/// </summary>
		/// <param name="word" type="string">
		///     <para>
		///         The word to generate suggestions on
		///     </para>
		/// </param>
		/// <remarks>
		///		This method sets the <see cref="Text"/> property to the word. 
		///		Then calls <see cref="TestWord"/> on the word to generate the need
		///		information for suggestions. Note that the Text, CurrentWord and WordIndex 
		///		properties are set when calling this method.
		/// </remarks>
		/// <seealso cref="CurrentWord"/>
		/// <seealso cref="Suggestions"/>
		/// <seealso cref="TestWord"/>
		public void Suggest(string word)
		{
			this.Text = word;
			if(!this.TestWord(word))
				this.Suggest();
		}
		/// <summary>
		///     Populates the <see cref="Suggestions"/> property with word suggestions
		///     for the <see cref="CurrentWord"/>
		/// </summary>
		/// <remarks>
		///		<see cref="TestWord"/> must have been called before calling this method
		/// </remarks>
		/// <seealso cref="CurrentWord"/>
		/// <seealso cref="Suggestions"/>
		/// <seealso cref="TestWord"/>
		public void Suggest()
		{
			
			
			// can't generate suggestions with out current word
			if (this.CurrentWord.Length == 0)
			{
				TraceWriter.TraceWarning("No current word");
				return;
			}

			this.Initialize();

			ArrayList tempSuggestion = new ArrayList();

			if ((_suggestionMode == SuggestionEnum.PhoneticNearMiss 
				|| _suggestionMode == SuggestionEnum.Phonetic)
				&& _dictionary.PhoneticRules.Count > 0)
			{
				// generate phonetic code for possible root word
				Hashtable codes = new Hashtable();
				foreach (string tempWord in _dictionary.PossibleBaseWords)
				{
					string tempCode = _dictionary.PhoneticCode(tempWord);
					if (tempCode.Length > 0 && !codes.ContainsKey(tempCode)) 
					{
						codes.Add(tempCode, tempCode);
					}
				}
				
				if (codes.Count > 0)
				{
					// search root words for phonetic codes
					foreach (Word word in _dictionary.BaseWords.Values)
					{
						if (codes.ContainsKey(word.PhoneticCode))
						{
							ArrayList words = _dictionary.ExpandWord(word);
							// add expanded words
							foreach (string expandedWord in words)
							{
								Word newWord = new Word();
								newWord.Text = expandedWord;
								newWord.EditDistance = this.EditDistance(this.CurrentWord, expandedWord);
								tempSuggestion.Add(newWord);
							}
						}
					}
				}
				TraceWriter.TraceVerbose("Suggestiongs Found with Phonetic Stratagy: {0}" , tempSuggestion.Count);
			}

			if (_suggestionMode == SuggestionEnum.PhoneticNearMiss 
				|| _suggestionMode == SuggestionEnum.NearMiss)
			{
				// suggestions for a typical fault of spelling, that
				// differs with more, than 1 letter from the right form.
				this.ReplaceChars(ref tempSuggestion);

				// swap out each char one by one and try all the tryme
				// chars in its place to see if that makes a good word
				this.BadChar(ref tempSuggestion);

				// try omitting one char of word at a time
				this.ExtraChar(ref tempSuggestion);

				// try inserting a tryme character before every letter
				this.ForgotChar(ref tempSuggestion);

				// split the string into two pieces after every char
				// if both pieces are good words make them a suggestion
				this.TwoWords(ref tempSuggestion);

				// try swapping adjacent chars one by one
				this.SwapChar(ref tempSuggestion);
			}

			TraceWriter.TraceVerbose("Total Suggestiongs Found: {0}" , tempSuggestion.Count);

			tempSuggestion.Sort();  // sorts by edit score
			_suggestions.Clear(); 

			for (int i = 0; i < tempSuggestion.Count; i++)
			{
				string word = ((Word)tempSuggestion[i]).Text;
				// looking for duplicates
				if (!_suggestions.Contains(word))
				{
					// populating the suggestion list
					_suggestions.Add(word);
				}

				if (_suggestions.Count >= _maxSuggestions && _maxSuggestions > 0)
				{
					break;
				}
			}

		} // suggest

		/// <summary>
		///     Checks to see if the word is in the dictionary
		/// </summary>
		/// <param name="word" type="string">
		///     <para>
		///         The word to check
		///     </para>
		/// </param>
		/// <returns>
		///     Returns true if word is found in dictionary
		/// </returns>
		public bool TestWord(string word)
		{
			this.Initialize();

			TraceWriter.TraceVerbose("Testing Word: {0}" , word);

			if (this.Dictionary.Contains(word))
			{
				return true;
			}
			else if (this.Dictionary.Contains(word.ToLower()))
			{
				return true;
			}
			return false;
		}

		#endregion

		#region public properties

		private bool _alertComplete = true;
		private WordDictionary _dictionary;
		private bool _ignoreAllCapsWords = true;
		private bool _ignoreHtml = true;
		private ArrayList _ignoreList = new ArrayList();
		private bool _ignoreWordsWithDigits = false;
		private int _maxSuggestions = 25;
		private Hashtable _replaceList = new Hashtable();
		private string _replacementWord = "";
		private bool _showDialog = true;
		private SuggestionForm _suggestionForm;
		private SuggestionEnum _suggestionMode = SuggestionEnum.PhoneticNearMiss;
		private ArrayList _suggestions = new ArrayList();
		private StringBuilder _text = new StringBuilder();
		private int _wordIndex = 0;


		/// <summary>
		///     The suggestion strategy to use when generating suggestions
		/// </summary>
		public enum SuggestionEnum
		{
			/// <summary>
			///     Combines the phonetic and near miss strategies
			/// </summary>
			PhoneticNearMiss,
			/// <summary>
			///     The phonetic strategy generates suggestions by word sound
			/// </summary>
			/// <remarks>
			///		This technique was developed by the open source project ASpell.net
			/// </remarks>
			Phonetic,
			/// <summary>
			///     The near miss strategy generates suggestion by replacing, 
			///     removing, adding chars to make words
			/// </summary>
			/// <remarks>
			///     This technique was developed by the open source spell checker ISpell
			/// </remarks>
			NearMiss
		}


		/// <summary>
		///     Display the 'Spell Check Complete' alert.
		/// </summary>
		[Browsable(true)]
		[DefaultValue(true)]
		[CategoryAttribute("Options")]
		[Description("Display the 'Spell Check Complete' alert.")]
		public bool AlertComplete
		{
			get { return _alertComplete; }
			set { _alertComplete = value; }
		}

		/// <summary>
		///     The current word being spell checked from the text property
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public string CurrentWord
		{
			get	
			{
				if(_words == null || _words.Count == 0)
					return string.Empty;
				else
					return _words[this.WordIndex].Value;
			}
		}

		/// <summary>
		///     The WordDictionary object to use when spell checking
		/// </summary>
		[Browsable(true)]
		[CategoryAttribute("Dictionary")]
		[Description("The WordDictionary object to use when spell checking")]
		public WordDictionary Dictionary
		{
			get 
			{
				if(!base.DesignMode && _dictionary == null)
					_dictionary = new WordDictionary();

				return _dictionary;
			}
			set 
			{
				if (value != null)
					_dictionary = value;
			}
		}


		/// <summary>
		///     Ignore words with all capital letters when spell checking
		/// </summary>
		[DefaultValue(true)]
		[CategoryAttribute("Options")]
		[Description("Ignore words with all capital letters when spell checking")]
		public bool IgnoreAllCapsWords
		{
			get {return _ignoreAllCapsWords;}
			set {_ignoreAllCapsWords = value;}
		}

		/// <summary>
		///     Ignore html tags when spell checking
		/// </summary>
		[DefaultValue(true)]
		[CategoryAttribute("Options")]
		[Description("Ignore html tags when spell checking")]
		public bool IgnoreHtml
		{
			get {return _ignoreHtml;}
			set {_ignoreHtml = value;}
		}

		/// <summary>
		///     List of words to automatically ignore
		/// </summary>
		/// <remarks>
		///		When <see cref="IgnoreAllWord"/> is clicked, the <see cref="CurrentWord"/> is added to this list
		/// </remarks>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ArrayList IgnoreList
		{
			get {return _ignoreList;}
		}

		/// <summary>
		///     Ignore words with digits when spell checking
		/// </summary>
		[DefaultValue(false)]
		[CategoryAttribute("Options")]
		[Description("Ignore words with digits when spell checking")]
		public bool IgnoreWordsWithDigits
		{
			get {return _ignoreWordsWithDigits;}
			set {_ignoreWordsWithDigits = value;}
		}

		/// <summary>
		///     The maximum number of suggestions to generate
		/// </summary>
		[DefaultValue(25)]
		[CategoryAttribute("Options")]
		[Description("The maximum number of suggestions to generate")]
		public int MaxSuggestions
		{
			get {return _maxSuggestions;}
			set {_maxSuggestions = value;}
		}

		/// <summary>
		///     List of words and replacement values to automatically replace
		/// </summary>
		/// <remarks>
		///		When <see cref="ReplaceAllWord"/> is clicked, the <see cref="CurrentWord"/> is added to this list
		/// </remarks>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public Hashtable ReplaceList
		{
			get {return _replaceList;}
		}

		/// <summary>
		///     The word to used when replacing the misspelled word
		/// </summary>
		/// <seealso cref="ReplaceAllWord"/>
		/// <seealso cref="ReplaceWord"/>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public string ReplacementWord
		{
			get {return _replacementWord;}
			set {_replacementWord = value.Trim();}
		}

		/// <summary>
		///     Determines if the spell checker should use its internal suggestions
		///     and options dialogs.
		/// </summary>
		[DefaultValue(true)]
		[CategoryAttribute("Options")]
		[Description("Determines if the spell checker should use its internal dialogs")]
		public bool ShowDialog
		{
			get {return _showDialog;}
			set 
			{
				_showDialog = value;
				if (_showDialog && _suggestionForm != null) 
					_suggestionForm.AttachEvents();
				else if(_suggestionForm != null)
					_suggestionForm.DetachEvents();
			}
		}


		/// <summary>
		///     The internal spelling suggestions dialog form
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public SuggestionForm SuggestionForm
		{
			get 
			{
				if(_suggestionForm == null)
					_suggestionForm = new SuggestionForm(this);

				return _suggestionForm;
			}
		}

		/// <summary>
		///     The suggestion strategy to use when generating suggestions
		/// </summary>
		[DefaultValue(SuggestionEnum.PhoneticNearMiss)]
		[CategoryAttribute("Options")]
		[Description("The suggestion strategy to use when generating suggestions")]
		public SuggestionEnum SuggestionMode
		{
			get {return _suggestionMode;}
			set {_suggestionMode = value;}
		}

		/// <summary>
		///     An array of word suggestions for the correct spelling of the misspelled word
		/// </summary>
		/// <seealso cref="Suggest"/>
		/// <seealso cref="SpellCheck"/>
		/// <seealso cref="MaxSuggestions"/>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ArrayList Suggestions
		{
			get {return _suggestions;}
		}

		/// <summary>
		///     The text to spell check
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public string Text
		{
			get {return _text.ToString();}
			set 
			{
				_text = new StringBuilder(value);
				this.CalculateWords();
				this.Reset();
			}
		}

		/// <summary>
		///     TextIndex is the index of the current text being spell checked
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public int TextIndex
		{
			get 
			{
				if (_words == null || _words.Count == 0)
					return 0;
	
				return _words[this.WordIndex].Index;			
			}
		}

		/// <summary>
		///     The number of words being spell checked
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public int WordCount
		{
			get 
			{
				if(_words == null)
					return 0;

				return _words.Count;
			}
		}

		/// <summary>
		///     WordIndex is the index of the current word being spell checked
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public int WordIndex
		{
			get 
			{
				if(_words == null)
					return 0;
				
				// make sure word index can't be higher then word count
				return Math.Max(0, Math.Min(_wordIndex, (this.WordCount-1)));	
			}
			set 
			{	
				_wordIndex = value;	
			}
		}

		#endregion

		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
		}

		#endregion

	} 
}

Open in new window

I dont see any code which shows any window. Are there any other code files?
Hi again,  This is what I found in the source directory.
// Copyright (c) 2003, Paul Welter
// All rights reserved.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;

using NetSpell.SpellChecker;
using NetSpell.SpellChecker.Dictionary;
using NetSpell.SpellChecker.Dictionary.Affix;
using NetSpell.SpellChecker.Dictionary.Phonetic;


namespace NetSpell.DictionaryBuild
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{

		private ArrayList _fileList = new ArrayList();
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.ToolBarButton copyBarButton;
		private System.Windows.Forms.ToolBarButton cutBarButton;
		private System.Windows.Forms.ToolBar editToolBar;
		private System.Windows.Forms.MainMenu mainMenu;
		private System.Windows.Forms.MenuItem menuEdit;
		private System.Windows.Forms.MenuItem menuEditCopy;
		private System.Windows.Forms.MenuItem menuEditCut;
		private System.Windows.Forms.MenuItem menuEditPaste;
		private System.Windows.Forms.MenuItem menuEditSelect;
		private System.Windows.Forms.MenuItem menuEditUndo;
		private System.Windows.Forms.MenuItem menuFile;
		private System.Windows.Forms.MenuItem menuFileClose;
		private System.Windows.Forms.MenuItem menuFileCloseAll;
		private System.Windows.Forms.MenuItem menuFileExit;
		private System.Windows.Forms.MenuItem menuFileNew;
		private System.Windows.Forms.MenuItem menuFileOpen;
		private System.Windows.Forms.MenuItem menuFileSave;
		private System.Windows.Forms.MenuItem menuFileSaveAll;
		private System.Windows.Forms.MenuItem menuHelp;
		private System.Windows.Forms.MenuItem menuHelpAbout;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.MenuItem menuItem9;
		private System.Windows.Forms.MenuItem menuWindow;
		private System.Windows.Forms.MenuItem menuWindowCascade;
		private System.Windows.Forms.MenuItem menuWindowHorizontal;
		private System.Windows.Forms.MenuItem menuWindowVertical;
		private System.Windows.Forms.ToolBarButton newBarButton;
		private System.Windows.Forms.ToolBarButton openBarButton;
		private System.Windows.Forms.ToolBarButton pasteBarButton;
		private System.Windows.Forms.ToolBarButton saveBarButton;
		private System.Windows.Forms.ToolBarButton toolBarButton11;
		private System.Windows.Forms.ToolBarButton toolBarButton4;
		private System.Windows.Forms.ToolBarButton toolBarButton8;
		private System.Windows.Forms.ImageList toolBarImages;
		internal System.Windows.Forms.StatusBar statusBar;
		private System.Windows.Forms.ToolBarButton undoBarButton;


		public MainForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

		}

		
		private void editToolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if(e.Button == newBarButton)
			{
				this.menuFileNew_Click(sender, new EventArgs());
			}
			else if(e.Button == openBarButton)
			{
				this.menuFileOpen_Click(sender, new EventArgs());
			}
			else if(e.Button == saveBarButton)
			{
				this.menuFileSave_Click(sender, new EventArgs());
			}
			else if(e.Button == cutBarButton)
			{
				this.menuEditCut_Click(sender, new EventArgs());
			}
			else if(e.Button == copyBarButton)
			{
				this.menuEditCopy_Click(sender, new EventArgs());
			}
			else if(e.Button == pasteBarButton)
			{
				this.menuEditPaste_Click(sender, new EventArgs());
			}
			else if(e.Button == undoBarButton)
			{
				this.menuEditUndo_Click(sender, new EventArgs());
			}
		}

		private TextBox GetActiveTextBox()
		{
			if (this.ActiveMdiChild != null)
			{
				if (this.ActiveMdiChild.ActiveControl != null)
				{
					if (this.ActiveMdiChild.ActiveControl.GetType() == typeof(TextBox))
					{
						return (TextBox)this.ActiveMdiChild.ActiveControl;
					}
				}
			}

			return null;
		}

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new MainForm());
		}

		private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			//this.menuFileCloseAll_Click(sender, new EventArgs());
		}

		private void menuEditCopy_Click(object sender, System.EventArgs e)
		{
			TextBox current = GetActiveTextBox();
			if (current != null)
			{
				current.Copy();
			}
		}

		private void menuEditCut_Click(object sender, System.EventArgs e)
		{
			TextBox current = GetActiveTextBox();
			if (current != null)
			{
				current.Cut();
			}

		}

		private void menuEditPaste_Click(object sender, System.EventArgs e)
		{
			TextBox current = GetActiveTextBox();
			if (current != null)
			{
				current.Paste();
			}

		}

		private void menuEditSelect_Click(object sender, System.EventArgs e)
		{
			TextBox current = GetActiveTextBox();
			if (current != null)
			{
				current.SelectAll();
			}

		}

		private void menuEditUndo_Click(object sender, System.EventArgs e)
		{
			TextBox current = GetActiveTextBox();
			if (current != null)
			{
				current.Undo();
			}

		}

		private void menuFileClose_Click(object sender, System.EventArgs e)
		{
			if (this.ActiveMdiChild != null)
			{
				this.ActiveMdiChild.Close();
			}
		}

		private void menuFileCloseAll_Click(object sender, System.EventArgs e)
		{
			foreach (Form child in this.MdiChildren)
			{
				child.Close();
			}
		}

		private void menuFileExit_Click(object sender, System.EventArgs e)
		{
			this.menuFileCloseAll_Click(sender, e);
			Application.Exit();
		}

		private void menuFileNew_Click(object sender, System.EventArgs e)
		{
			DictionaryForm newForm = new DictionaryForm();
			newForm.MdiParent = this;
			newForm.Show();
		}

		private void menuFileOpen_Click(object sender, System.EventArgs e)
		{
			DictionaryForm newForm = new DictionaryForm();

			if (newForm.OpenDictionary())
			{
				newForm.MdiParent = this;
				newForm.Show();
			}
		}

		private void menuFileSave_Click(object sender, System.EventArgs e)
		{
			if (this.ActiveMdiChild != null)
			{
				DictionaryForm child = (DictionaryForm)this.ActiveMdiChild;
				child.SaveDictionary();
			}
		}

		private void menuFileSaveAll_Click(object sender, System.EventArgs e)
		{
			foreach (DictionaryForm child in this.MdiChildren)
			{
				child.SaveDictionary();
			}
		}

		private void menuHelpAbout_Click(object sender, System.EventArgs e)
		{
			AboutForm about = new AboutForm();
			about.ShowDialog(this);
		}

	

		private void menuWindowCascade_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.Cascade);
		}

		private void menuWindowHorizontal_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.TileHorizontal);
		}

		private void menuWindowVertical_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.TileVertical);
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
			this.statusBar = new System.Windows.Forms.StatusBar();
			this.mainMenu = new System.Windows.Forms.MainMenu();
			this.menuFile = new System.Windows.Forms.MenuItem();
			this.menuFileNew = new System.Windows.Forms.MenuItem();
			this.menuFileOpen = new System.Windows.Forms.MenuItem();
			this.menuFileClose = new System.Windows.Forms.MenuItem();
			this.menuFileCloseAll = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuFileSave = new System.Windows.Forms.MenuItem();
			this.menuFileSaveAll = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.menuFileExit = new System.Windows.Forms.MenuItem();
			this.menuEdit = new System.Windows.Forms.MenuItem();
			this.menuEditUndo = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuEditCut = new System.Windows.Forms.MenuItem();
			this.menuEditCopy = new System.Windows.Forms.MenuItem();
			this.menuEditPaste = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.menuEditSelect = new System.Windows.Forms.MenuItem();
			this.menuWindow = new System.Windows.Forms.MenuItem();
			this.menuWindowHorizontal = new System.Windows.Forms.MenuItem();
			this.menuWindowVertical = new System.Windows.Forms.MenuItem();
			this.menuWindowCascade = new System.Windows.Forms.MenuItem();
			this.menuHelp = new System.Windows.Forms.MenuItem();
			this.menuHelpAbout = new System.Windows.Forms.MenuItem();
			this.toolBarImages = new System.Windows.Forms.ImageList(this.components);
			this.editToolBar = new System.Windows.Forms.ToolBar();
			this.newBarButton = new System.Windows.Forms.ToolBarButton();
			this.openBarButton = new System.Windows.Forms.ToolBarButton();
			this.saveBarButton = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
			this.cutBarButton = new System.Windows.Forms.ToolBarButton();
			this.copyBarButton = new System.Windows.Forms.ToolBarButton();
			this.pasteBarButton = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton8 = new System.Windows.Forms.ToolBarButton();
			this.undoBarButton = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton11 = new System.Windows.Forms.ToolBarButton();
			this.SuspendLayout();
			// 
			// statusBar
			// 
			this.statusBar.Location = new System.Drawing.Point(0, 401);
			this.statusBar.Name = "statusBar";
			this.statusBar.Size = new System.Drawing.Size(648, 16);
			this.statusBar.TabIndex = 0;
			// 
			// mainMenu
			// 
			this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuFile,
																					 this.menuEdit,
																					 this.menuWindow,
																					 this.menuHelp});
			// 
			// menuFile
			// 
			this.menuFile.Index = 0;
			this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuFileNew,
																					 this.menuFileOpen,
																					 this.menuFileClose,
																					 this.menuFileCloseAll,
																					 this.menuItem5,
																					 this.menuFileSave,
																					 this.menuFileSaveAll,
																					 this.menuItem9,
																					 this.menuFileExit});
			this.menuFile.Text = "File";
			// 
			// menuFileNew
			// 
			this.menuFileNew.Index = 0;
			this.menuFileNew.Text = "New";
			this.menuFileNew.Click += new System.EventHandler(this.menuFileNew_Click);
			// 
			// menuFileOpen
			// 
			this.menuFileOpen.Index = 1;
			this.menuFileOpen.Text = "Open...";
			this.menuFileOpen.Click += new System.EventHandler(this.menuFileOpen_Click);
			// 
			// menuFileClose
			// 
			this.menuFileClose.Index = 2;
			this.menuFileClose.Text = "Close";
			this.menuFileClose.Click += new System.EventHandler(this.menuFileClose_Click);
			// 
			// menuFileCloseAll
			// 
			this.menuFileCloseAll.Index = 3;
			this.menuFileCloseAll.Text = "Close All";
			this.menuFileCloseAll.Click += new System.EventHandler(this.menuFileCloseAll_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 4;
			this.menuItem5.Text = "-";
			// 
			// menuFileSave
			// 
			this.menuFileSave.Index = 5;
			this.menuFileSave.Text = "Save";
			this.menuFileSave.Click += new System.EventHandler(this.menuFileSave_Click);
			// 
			// menuFileSaveAll
			// 
			this.menuFileSaveAll.Index = 6;
			this.menuFileSaveAll.Text = "Save All";
			this.menuFileSaveAll.Click += new System.EventHandler(this.menuFileSaveAll_Click);
			// 
			// menuItem9
			// 
			this.menuItem9.Index = 7;
			this.menuItem9.Text = "-";
			// 
			// menuFileExit
			// 
			this.menuFileExit.Index = 8;
			this.menuFileExit.Text = "Exit";
			this.menuFileExit.Click += new System.EventHandler(this.menuFileExit_Click);
			// 
			// menuEdit
			// 
			this.menuEdit.Index = 1;
			this.menuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuEditUndo,
																					 this.menuItem3,
																					 this.menuEditCut,
																					 this.menuEditCopy,
																					 this.menuEditPaste,
																					 this.menuItem8,
																					 this.menuEditSelect});
			this.menuEdit.Text = "Edit";
			// 
			// menuEditUndo
			// 
			this.menuEditUndo.Index = 0;
			this.menuEditUndo.Text = "Undo";
			this.menuEditUndo.Click += new System.EventHandler(this.menuEditUndo_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.Text = "-";
			// 
			// menuEditCut
			// 
			this.menuEditCut.Index = 2;
			this.menuEditCut.Text = "Cut";
			this.menuEditCut.Click += new System.EventHandler(this.menuEditCut_Click);
			// 
			// menuEditCopy
			// 
			this.menuEditCopy.Index = 3;
			this.menuEditCopy.Text = "Copy";
			this.menuEditCopy.Click += new System.EventHandler(this.menuEditCopy_Click);
			// 
			// menuEditPaste
			// 
			this.menuEditPaste.Index = 4;
			this.menuEditPaste.Text = "Paste";
			this.menuEditPaste.Click += new System.EventHandler(this.menuEditPaste_Click);
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 5;
			this.menuItem8.Text = "-";
			// 
			// menuEditSelect
			// 
			this.menuEditSelect.Index = 6;
			this.menuEditSelect.Text = "Select All";
			this.menuEditSelect.Click += new System.EventHandler(this.menuEditSelect_Click);
			// 
			// menuWindow
			// 
			this.menuWindow.Index = 2;
			this.menuWindow.MdiList = true;
			this.menuWindow.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					   this.menuWindowHorizontal,
																					   this.menuWindowVertical,
																					   this.menuWindowCascade});
			this.menuWindow.MergeOrder = 7;
			this.menuWindow.Text = "Window";
			// 
			// menuWindowHorizontal
			// 
			this.menuWindowHorizontal.Index = 0;
			this.menuWindowHorizontal.Text = "Tile Horizontal";
			this.menuWindowHorizontal.Click += new System.EventHandler(this.menuWindowHorizontal_Click);
			// 
			// menuWindowVertical
			// 
			this.menuWindowVertical.Index = 1;
			this.menuWindowVertical.Text = "Tile Vertical";
			this.menuWindowVertical.Click += new System.EventHandler(this.menuWindowVertical_Click);
			// 
			// menuWindowCascade
			// 
			this.menuWindowCascade.Index = 2;
			this.menuWindowCascade.Text = "Cascade";
			this.menuWindowCascade.Click += new System.EventHandler(this.menuWindowCascade_Click);
			// 
			// menuHelp
			// 
			this.menuHelp.Index = 3;
			this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuHelpAbout});
			this.menuHelp.MergeOrder = 8;
			this.menuHelp.Text = "Help";
			// 
			// menuHelpAbout
			// 
			this.menuHelpAbout.Index = 0;
			this.menuHelpAbout.Text = "About";
			this.menuHelpAbout.Click += new System.EventHandler(this.menuHelpAbout_Click);
			// 
			// toolBarImages
			// 
			this.toolBarImages.ImageSize = new System.Drawing.Size(16, 16);
			this.toolBarImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("toolBarImages.ImageStream")));
			this.toolBarImages.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// editToolBar
			// 
			this.editToolBar.AutoSize = false;
			this.editToolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						   this.newBarButton,
																						   this.openBarButton,
																						   this.saveBarButton,
																						   this.toolBarButton4,
																						   this.cutBarButton,
																						   this.copyBarButton,
																						   this.pasteBarButton,
																						   this.toolBarButton8,
																						   this.undoBarButton,
																						   this.toolBarButton11});
			this.editToolBar.ButtonSize = new System.Drawing.Size(24, 24);
			this.editToolBar.DropDownArrows = true;
			this.editToolBar.ImageList = this.toolBarImages;
			this.editToolBar.Location = new System.Drawing.Point(0, 0);
			this.editToolBar.Name = "editToolBar";
			this.editToolBar.ShowToolTips = true;
			this.editToolBar.Size = new System.Drawing.Size(648, 32);
			this.editToolBar.TabIndex = 1;
			this.editToolBar.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
			this.editToolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.editToolBar_ButtonClick);
			// 
			// newBarButton
			// 
			this.newBarButton.ImageIndex = 4;
			this.newBarButton.ToolTipText = "New";
			// 
			// openBarButton
			// 
			this.openBarButton.ImageIndex = 5;
			this.openBarButton.ToolTipText = "Open";
			// 
			// saveBarButton
			// 
			this.saveBarButton.ImageIndex = 8;
			this.saveBarButton.ToolTipText = "Save";
			// 
			// toolBarButton4
			// 
			this.toolBarButton4.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// cutBarButton
			// 
			this.cutBarButton.ImageIndex = 1;
			this.cutBarButton.ToolTipText = "Cut";
			// 
			// copyBarButton
			// 
			this.copyBarButton.ImageIndex = 0;
			this.copyBarButton.ToolTipText = "Copy";
			// 
			// pasteBarButton
			// 
			this.pasteBarButton.ImageIndex = 6;
			this.pasteBarButton.ToolTipText = "Paste";
			// 
			// toolBarButton8
			// 
			this.toolBarButton8.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// undoBarButton
			// 
			this.undoBarButton.ImageIndex = 10;
			this.undoBarButton.ToolTipText = "Undo";
			// 
			// toolBarButton11
			// 
			this.toolBarButton11.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(648, 417);
			this.Controls.Add(this.editToolBar);
			this.Controls.Add(this.statusBar);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.IsMdiContainer = true;
			this.Menu = this.mainMenu;
			this.Name = "MainForm";
			this.Text = "Dictionary Build";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
			this.ResumeLayout(false);

		}
#endregion


	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello,

I think I found the answer, but thanks for poiting me in the right direction.

I added this code in the clSpellCheck class and I call it whenever I add a record.  Thiis checks whether the NetSpell screen is still there and if it is, it disposes it.

    Public Sub CloseSpellMe()

        'dispose the NetSpell window.
        If Not (SpellChecker.SuggestionForm) Is Nothing Then
            SpellChecker.SuggestionForm.Dispose()
            SpellChecker.Dispose()
        End If

    End Sub
Glad you nailed it :-)