Why does using CHARFORMAT2 to set superscript or subscript apply the change to the entire RichTextBox?

Robert Gustafson 606 Reputation points
2022-11-30T04:59:10.09+00:00

WHAT I HAVE:
Visual Basic 2019, WinForms, NET 4.0+

MY PROBLEM:
I've written code to use SendMessage and the CHARFORMAT2 structure to set superscript or subscript to a selected region of text. The problem is, it doesn't just apply a style to the selection only; it applies it the the entire text box! What am I doing wrong?

Please give an answer ASAP, in VB.NET, and as simply as possible.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,828 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
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Robert Gustafson 606 Reputation points
    2022-11-30T05:03:45.403+00:00

    I figure it out, I have the set one of the parameters to SCF_SELECTION!

    0 comments No comments