How do I change the caret colour?

SyntaxEditor for Windows Forms Forum

Posted 2 years ago by RobotGizmo
Version: 22.1.0

Hello, I am using the latest WinForms version of SyntaxEditor and I can't figure out how to change the caret colour. I'm using the dark theme vssettings file from the sample project and I've set the backcolor to black and the forecolor to white. No matter what I do the caret always black. Is there a way to change the blinking caret's colour? Thanks!

Comments (2)

Answer - Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Jon,

The caret should be automatically using Black or White based on what text area background it detects.  It first examines SyntaxEditor.BackColor.  If that Color value is Empty, it will look at the highlighting style registered for the PlainText display classification type to see what its Background is.

I just did a quick test by putting this at the end of the MainControl.cs constructor for our main SyntaxEditor demo and I see a white caret on a black text area background:

editor.BackColor = Color.Black;

Note this is in our codebase for the upcoming maintenance release, but I believe it worked the same in v22.1.0.

There also is this option that you can use in the WinForms SyntaxEditor, which tries to XOR render the caret on top of what's below it:

editor.UseInvertedCaret = true;

Actipro Software Support

Posted 2 years ago by RobotGizmo

For some reason it wasn't detecting the colour correctly but using the UseInvertedCaret setting fixed the issue. Thanks!

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.