I wrote a custom control in C# that inherits from the RichTextBox. The purpose of this control is to contain all improvements and changes, such as modified line numbering and having the control repaint itself only when it should.
Yesterday, I noticed memory spikes (and often, OOM exceptions) when accessing the Lines property of this control (there are 600,000+ lines in the control at times). I coded workarounds that no longer involve it, but I would still like to completely remove it so people who use my control in the future do not use it.
The Lines property is System.Windows.Forms.TextBoxBase.Lines. Ideally, I'd like the string[] for this property to never be touched; when I load text in the control, I do NOT want the control to do anything to fill this lines property (because it's completely pointless and is consuming some time and resources).
Anyone have any ideas?
EDIT: I tried
public override string[] Lines { get { return null; } set { ; } // do nothing }
But VS says "cannot override inherited member System.Windows.Forms.TextBoxBase.Lines.get because it is not marked virtual, abstract, or override.
So it looks like I can't override or remove it. I think the RichTextBox is setting the property because it is filled after change the text. Is there a way for me to capture and handle that message?