Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
« »

Simulating "delete next word" of MS Word

Blogged by Björn Meyer on November 09, 2005 and tagged with Samples, .NET.

MS Word offers a shortcut (CTRL + DEL) to delete the complete next word. This is quite simple to implement using TX Text Control .NET. We utilize the KeyDown event of TX Text Control to trap the specific keystrokes. Then we use the Find method to search for the next space character. If this space character exists, the text is selected and deleted.

private void textControl1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.Control == true && e.KeyCode == System.Windows.Forms.Keys.Delete)
{
int startPos = textControl1.Selection.Start;
int endPos = textControl1.Find(" ", startPos, TXTextControl.FindOptions.NoMessageBox);
if(endPos != -1)
{
textControl1.Select(startPos, endPos - startPos);
textControl1.Selection.Text = "";
}
else
e.Handled = true;
}
}
« Prev:Using Tabs in TX Text Control
» Next:TX Text Control .NET Server 12.0 released

Comments

If you would like to comment on this blog entry, please post a comment.

External verification page for ISO 9000:2000 certificate
ISO 9001:2000
certified