Products Technologies Demo Docs Blog Support Company
TX Text Control 34.0 SP1 has been released - Learn more

Windows Forms: Removing the Next Word Right to the Input Position on CTRL + DEL

MS Word provides a functionality to remove the next word at the current input position by pressing the key combination CTRL + DEL. TX Text Control implements many pre-defined key combinations and mouse selections with the Smart Selection Interface. But thanks to the flexible API and the complete event set, additional combinations can be easily implemented. The following code shows how to trap the key combination CTRL + DEL to remove the next word right to the input position. Happy coding!

Windows Forms: Removing the Next Word Right to the Input Position on CTRL + DEL

MS Word provides a functionality to remove the next word at the current input position by pressing the key combination CTRL + DEL. TX Text Control implements many pre-defined key combinations and mouse selections with the Smart Selection Interface.

But thanks to the flexible API and the complete event set, additional combinations can be easily implemented. The following code shows how to trap the key combination CTRL + DEL to remove the next word right to the input position.

Happy coding!

private void textControl1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Control && e.KeyCode == Keys.Delete)
    {
        // get the current paragraph at the input position
        TXTextControl.Paragraph curParagraph =
            textControl1.Paragraphs.GetItem(textControl1.Selection.Start);
        
        // return the text beginning at the input position
        // until the end of the paragraph
        string sParagraph = curParagraph.Text.Substring(
            textControl1.Selection.Start - curParagraph.Start + 1);

        // search for delimiters and return the positions
        List<int> indexes = Regex.Matches(sParagraph, @"[^\w]+").Cast<Match>()
                .Select(m => m.Index)
                .ToList();

        // if delimiters are found, select the text until the next
        // delimiter and remove the text
        if (indexes.Count > 0)
        {
            textControl1.Selection.Length = indexes[0] + 1;
            textControl1.Selection.Text = "";

            // cancel the original event handling
            e.Handled = true;
        }
    }
}

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Windows Forms

Text Control combines the power of a reporting tool and an easy-to-use WYSIWYG word processor - fully programmable and embeddable in your Windows Forms application. TX Text Control .NET for Windows Forms is a royalty-free, fully programmable rich edit control that offers developers a broad range of word processing features in a reusable component for Visual Studio.

See Windows Forms products

Related Posts

ASP.NETWindows FormsWPF

TX Text Control 34.0 SP1 is Now Available: What's New in the Latest Version

TX Text Control 34.0 Service Pack 1 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ActiveXASP.NETWindows Forms

Introducing TX Text Control 34.0: Your Next Leap in Document Processing.

We are happy to announce the release of TX Text Control 34.0. This version is packed with new features and enhancements that will elevate your document processing experience. This version…


ASP.NETWindows FormsWPF

Sneak Peek: TX Text Control 34.0 Coming November 2025

We are excited to announce the upcoming release of TX Text Control 34.0, scheduled for November 2025. This update brings a host of new features and improvements to enhance your document processing…


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 3 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 2 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…

Summarize this blog post with:

Share on this blog post on: