Muvlo Posted January 6, 2003 Posted January 6, 2003 Hi. :) I'm trying to create a special TextBox that gives me control over the appearance of text in that box per character. This needs to be a completely visual effect. The program should see it as normal text. I've seen several tutorials with about changing the border of a TextBox or something like that, which seems pretty close to what I want. Unfortunatly, I was never able to get any of these to work. :-\ I'd appreciate any help you can give me. :) -Muvlo Quote
*Experts* Volte Posted January 6, 2003 *Experts* Posted January 6, 2003 You can try using a RichTextBox control. By setting the SelectionStart property to the position of the character you want to alter, and set SelectionLength to 1, then you can use the other Selection properties to modify the fonts and colors. The Text property will still return the normal text. Look in the Code Library for an example of a RoundedTextBox by Bucky. You can set the rounding to 0 and still change the border color, leaving you with a colored, square textbox. You have to modify Bucky's control to support the RichTextBox (not very hard at all) if you want both char-by-char control AND colored border. I believe that all you have to do is Inherit the RichTextBox instead of the normal TextBox. Quote
Muvlo Posted January 6, 2003 Author Posted January 6, 2003 A RichTextBox is a good idea, but what if the user wanted to undo something? Unless there is a way to control undo, they'd have to go back through a lot of little changes to formating. -Muvlo Quote
Muvlo Posted January 7, 2003 Author Posted January 7, 2003 In case someone finds this code useful, here is what I've ended up doing: Imports System.Windows.Forms Imports System.Drawing Public Class CodeBox Inherits TextBox Public Sub New() MyBase.New() Me.SetStyle(ControlStyles.UserPaint, True) End Sub Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) Dim g As Graphics = e.Graphics 'Insert whatever graphics code is needed... End Sub End Class This class is compiled as a class library, and it can then be used as a control. :) -Muvlo Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.