Richtext Box question
-
Has anybody ever drawn the red squigly lines that show up say in Word or other apps under a word when it is misspelled? I have come up with a way but it is not reliable to underline all words. My method gets messed up with tab chars and also hidden text. I suspect the same would be true for tables and inserted pictures. Thanks in advance, Eric
-
Has anybody ever drawn the red squigly lines that show up say in Word or other apps under a word when it is misspelled? I have come up with a way but it is not reliable to underline all words. My method gets messed up with tab chars and also hidden text. I suspect the same would be true for tables and inserted pictures. Thanks in advance, Eric
From my knowledge, it is not directly possible to use the rtb class to draw the Office-Style underlines. However, you can have an effective selection method by saving the selected text and creating custom functions to get text from it - even with hidden text
-
Has anybody ever drawn the red squigly lines that show up say in Word or other apps under a word when it is misspelled? I have come up with a way but it is not reliable to underline all words. My method gets messed up with tab chars and also hidden text. I suspect the same would be true for tables and inserted pictures. Thanks in advance, Eric
I think you would probably have to directly draw the lines on the control, either using RichTextBox.CreateGraphis() or by creating a class that inherits from RichTextBox, and overriding RichtextBox.OnPaint
-
Has anybody ever drawn the red squigly lines that show up say in Word or other apps under a word when it is misspelled? I have come up with a way but it is not reliable to underline all words. My method gets messed up with tab chars and also hidden text. I suspect the same would be true for tables and inserted pictures. Thanks in advance, Eric
-
Its possible to draw the line using the approach mentioned. However, the difficulty I'm having is reliably calculating the coordinates of the beginning of the word that needs to be marked with the squiggly. Any suggestions there? Thanks again, Eric
Use the
GetPositionFromCharIndex
method. -
Has anybody ever drawn the red squigly lines that show up say in Word or other apps under a word when it is misspelled? I have come up with a way but it is not reliable to underline all words. My method gets messed up with tab chars and also hidden text. I suspect the same would be true for tables and inserted pictures. Thanks in advance, Eric
Hi! The Rich Edit control that's actually the core control underneath the RichTextBox can display underlines (even the squiggly ones), but setting the corresponding character styles is not possible directly with the regular RichTextBox. You'll have to send EM_SETCHARFORMAT messages to the rtb to enable underlining in a given style. You can't have an underline color that's different from the text foreground color, though. You might want to look up the CHARFORMAT2 structure in the Platform SDK documentation on the different options you have to underline text within a rich edit control (and thus in a RichTextBox). Regards, mav -- modified at 7:47 Saturday 4th February, 2006 Just found out that my statement on the underline color was incorrect. You CAN have different underline colors, althouth it's not documented in the CHARFORMAT2 struct. The upper 4 bits of the bUnderlineType determine the color.
-
Its possible to draw the line using the approach mentioned. However, the difficulty I'm having is reliably calculating the coordinates of the beginning of the word that needs to be marked with the squiggly. Any suggestions there? Thanks again, Eric
Will u please post the code!!!!!!!!