How do I keep a RichTextBox from changing the case of selected text when I press F3?!

Robert Gustafson 606 Reputation points
2022-11-27T08:08:46.107+00:00

WHAT I HAVE:
Visual Basic 2019, WinForms, .NET 4+

MY PROBLEM:
I've created a custom control (configured for .NET 4.0+) which uses a RichTextBox as a constituent control, and the RichTextBox is hooked up to a ContextMenuStrip which includes options (among others) of Find ( Ctrl+F ), Find Next ( F3 ), and Find Previous ( Shift+F3 ). The problem occurs when I use the shortcut keys to look for and highlight subsequent and previous occurrences of a fore-specified search string. Theoretically, the context-menu shortcuts should preempt any default behavior for the keys in the text box. However. it doesn't: Whenever the found text is highlighted, the case of the highlighted text is changed. The only way I can seem to guarantee that the text doesn't change is to move to caret to it without highlighting it--which isn't particularly useful or convenient for an end user. This problem used to manifest itself only when the host project using my custom control was configured for .NET 4.7.1 or higher--but now it's happening even when the host project is set for lower platforms!

Is there a way to disable the auto-case-changing of highlighted text that currently happens whenever * F3 * is pressed? I need a solution ASAP, in VB.NET, and as simply as possible--as I'm on a tight schedule!!

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,828 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,570 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Robert Gustafson 606 Reputation points
    2022-11-27T09:38:09.593+00:00

    Actually, it was the spell-checker tool, not the RichTextBox that was to blame. Problem solved!

    0 comments No comments