Seand2436

I have a class I created that Inherits the RichTextBox class. Im trying to create a RichTextBox that will have a constant set of colors available. Currently I have a Constant that holds my color table and replaces the active color table with this String if it is modified. In order to prevent it from Replacing the Rtf code every time, I have another Constant which holds a line of Rtf code that uses every color available (since those colors will disappear if unused.) Is there an alternative way of accomplishing this

Re: Visual Basic General RichTextBox Color Table

Bruno Yu - MSFT

Seand2436,

I think your solution is very well to fit your demand. I agree with your solution, it is effective and fine.

According to the description on the question, my assumption is like this: a constant set of colors is for the background. So I would like to provide you the following advice:

1. Please try to set the BackColor to SystemColors.Window (or other color you want).

2. The BackColor is already set to SystemColors.Window. Turn ReadOnly on just like: RichTextBox.ReadOnly = True

I hope I can understand your question correctly and hope that can help you from an alternative way. Thanks again for your question.






Re: Visual Basic General RichTextBox Color Table

Seand2436

Thanks for your response Bruno. The colors are intended for the actual text. Your comment on the ReadOnly property was good, I had forgotten to set that. Allthough I would like this RichTextBox to remain ReadOnly, I don't know how to do this from an Inherited class. I would also like to mention that i have added RTF code to protect to line containing my color "tests" so that is not an issue, even if the RichTextBox is not ReadOnly. I am also looking for an alternative to my "test" line if one does exist for this problem.



Re: Visual Basic General RichTextBox Color Table

Bruno Yu - MSFT

Seand2436,

I appologize for the delay. Please write a readonly property for your inherited class RichTextBox as below:

Code Snippet

Public ReadOnly Property RichTextBox()

Get

Return TestColor

End Get

End Property

Hope that can help you set the inherited class ReadOnly property to True.