To spell check a TextBlock control;
Add this class to your project
public class TextBlockAdapter : ISpellCheckableTextComponent
{
int selectionStart, selectionLength;
TextBlock tb;
public TextBlockAdapter(TextBlock block)
{
tb = block;
}
public void Dispose()
{
}
public event EventHandler Disposed;
public bool Enabled
{
get { return true; }
}
public event EventHandler GotFocus;
public bool HideSelection
{
get
{
return false;
}
set
{
}
}
public bool ReadOnly
{
get { return false; }
}
public void ScrollToCaret()
{
}
public string SelectedText
{
get
{
return tb.Text.Substring(SelectionStart, SelectionLength);
}
set
{
tb.Text=tb.Text.Substring(0, SelectionStart)+value+tb.Text.Substring(SelectionStart+SelectionLength);
}
}
public int SelectionLength
{
get
{
return selectionLength; ;
}
set
{
selectionLength = value;
}
}
public int SelectionStart
{
get
{
return selectionStart;
}
set
{
selectionStart = value;
}
}
public string Text
{
get
{
return tb.Text;
}
set
{
tb.Text = value;
}
}
}
Set it up to be spell checked like this
rapidSpellDialog1.AddTextComponent(new TextBlockAdapter(textBlock1));
|