Saturday, January 12, 2013

Shading Style in RichTextBox 5.0

I am extending the RichEdit 5.0 control in a C# application that I am writing and was playing with using paragraph shading. There are several issues with this. The .NET 4.x RichTextBox control does not expose properties for accessing shading, though the underlying Win32 control does. If we use Win32 messages we can get and set the shading properties. That is enough work on its own, but the second problem we have is that the documentation is not so great. The PARAFORMAT2 documentation lists the various settings for the wShadingStyle member, but they seem to be inaccurate and difficult to visualize what the shading patterns look like. The third problem is that the control itself generates and honors the correct RTF for shading but does not actually display it (as of this writing), though the RTF text can be pasted into MS Word or loaded via RTF and the shading does display.

Shading with the RichTextBox control is not fully baked yet, but I am assuming future controls will fully implement it. You may find the following diagram that describes the settings helpful for PARAFORMAT2.wShadingStyle. Please note that these do not match the values shown in the documentation referenced above.

No comments:

Post a Comment