RobertAlanGustafsonII
Active member
- Joined
- Sep 16, 2023
- Messages
- 39
- Programming Experience
- 10+
WHAT I HAVE:
Visual Basic 2019, WinForms, RichTextBox, .NET Framework 4.6+
MY ISSUE:
When compliing a WinForms app using a RichTextBox for .NET Framework 4.6.x or lower, the properties Text, SelText, SelectionLength, and SelRtf all properly account for any hidden (invisible) text when being read. This is not so when compiling for .NET Framework 4.7+!!! While I can create workarounds for the first 3 properties by relying on the non-public properties WindowText, curSelStart, and curSelEnd, this technique will not work for SelRtf--since WindowText only returns the full plain text (including hidden text), and the Substring method wouldn't work properly with curSelStart and curSelEnd when dealing with a rich text string anyway.
Generally, SelRtf (when working with .NET Framework 4.7+) only reliably returns hidden rich text when it's surrounded within the selection by visible text. If one has
RichTextBox1.Rtf = {rtf1 {vText1 \v iText1 \v0 vText2 \v iText2\v0}}"
then whether one gets all hidden text of a selection depends on the values set for RichTextBox1.SelectionStart and RichTextBox1.SelectionLength. (BTW, RichTextBox1.Rtf will reliably get all hidden text for the full document, regardless of the platform version.)
Is there a way (i.e., using Win32 or some other) to get the full rich text of a selected region--including any hidden text--when using .NET Framework 4.7+?
Please provide answers ASAP, in VB.NET, and as simply as possible. (BTW, ideally, I shouldn't have to derive another type control from RichTextBox.)
Visual Basic 2019, WinForms, RichTextBox, .NET Framework 4.6+
MY ISSUE:
When compliing a WinForms app using a RichTextBox for .NET Framework 4.6.x or lower, the properties Text, SelText, SelectionLength, and SelRtf all properly account for any hidden (invisible) text when being read. This is not so when compiling for .NET Framework 4.7+!!! While I can create workarounds for the first 3 properties by relying on the non-public properties WindowText, curSelStart, and curSelEnd, this technique will not work for SelRtf--since WindowText only returns the full plain text (including hidden text), and the Substring method wouldn't work properly with curSelStart and curSelEnd when dealing with a rich text string anyway.
Generally, SelRtf (when working with .NET Framework 4.7+) only reliably returns hidden rich text when it's surrounded within the selection by visible text. If one has
RichTextBox1.Rtf = {rtf1 {vText1 \v iText1 \v0 vText2 \v iText2\v0}}"
then whether one gets all hidden text of a selection depends on the values set for RichTextBox1.SelectionStart and RichTextBox1.SelectionLength. (BTW, RichTextBox1.Rtf will reliably get all hidden text for the full document, regardless of the platform version.)
Is there a way (i.e., using Win32 or some other) to get the full rich text of a selected region--including any hidden text--when using .NET Framework 4.7+?
Please provide answers ASAP, in VB.NET, and as simply as possible. (BTW, ideally, I shouldn't have to derive another type control from RichTextBox.)