Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I need to be able to determine if insert mode is active in a WPF RichTextBox. I tried using reflection like so:
 
PropertyInfo pInfo = this.GetType().GetProperty("_OvertypeMode", BindingFlags.NonPublic | BindingFlags.Instance);
 
However, the property _OverTypeMode doesn't exist in the RichTextBox that I could find.
 
Does anyone know how to do this?
 
Google was no help.
Posted 2-Aug-12 10:03am
Comments
Sergey Alexandrovich Kryukov at 2-Aug-12 16:16pm
   
How do you know it's supposed to exist? Apparently, there is no access to insert/overwrite switch... have no idea how to achieve that.
--SA
Kenneth Haugland at 2-Aug-12 16:27pm
   
Must be there somewere, otherwise the value on insert would be set globally, no?
Sergey Alexandrovich Kryukov at 2-Aug-12 17:10pm
   
...already forgot how it works... In some editors, Insert key is ignored (and I like it), in some it is not... I just tested CMD vs my editor based on native Windows RichEdit control -- they are independent. But maybe you are right in your last statement, below...
--SA
Kenneth Haugland at 2-Aug-12 17:27pm
   
Perhaps you could ovverride the Insert function by stopping the text addition/insert in the Preview Text input?
Sorry, didnt see that he ha solved it...
Kenneth Haugland at 2-Aug-12 16:31pm
   
THe value could be found by Keyboard.IsKeyToggled(Key.Insert) and you assume that this is stored somewere in the RTB. At least it seems that IsKeyToggeled applies to all text elements in WPF, and sould perhaps stem from TextBoxBase control, whitch RTB implements.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I found out that in WPF, a TextBox or RichTextBox always defaults to Insert being ON when the control is instantiated. With that knowledge, I simply track the pressing of Key.Insert, and maintain my own variable that indicates status.
 
Problem solved.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 2 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid