Why doesn't the Syntax Editor use the render for backcolor?

SyntaxEditor for Windows Forms Forum

The latest build of this product (v24.1.0) was released 3 months ago, which was before this thread was created.
Posted 12 days ago by AF
Version: 24.1.0

Hi, in your SDI sample, you set the renderer but then must also set the BackColor to be the same as the selected theme...

// Configure the editor with the per-instance renderer
editor.Renderer = renderer;

// Update colors on this control to be consistent with the color scheme
// The color properties for SyntaxEditor.BackColor and SyntaxEditor.ForeColor
//   are only used when the corresponding color properties of the "Plain Text" highlighting
//   style are undefined (which is the default).
var colorScheme = renderer.ColorScheme;
editorPanel.BackColor = colorScheme.GetKnownColor(KnownColor.Control);
editor.BackColor = colorScheme.GetKnownColor(KnownColor.Window);
editor.ForeColor = colorScheme.GetKnownColor(KnownColor.WindowText);

This seems wrong as the BackColor of the renderer should surely be applied automatically?

[Modified 11 days ago]

Comments (1)

Answer - Posted 11 days ago by Actipro Software Support - Cleveland, OH, USA

SyntaxEditor is designed, by default, to inherit the BackColor and ForeColor from the containing window and apply that to any text which does not have an explicit highlighting style (i.e., the "Plain Text" style).

This decision was made so that when SyntaxEditor is used in scenarios that do not require highlighting styles (like logging text output), the control theme would be consistent with a native multi-line TextBox.  For developers that also use custom application themes, this ensures the theme they apply naturally flows to the SyntaxEditor.

In general, not having BackColor and ForeColor set automatically on the SyntaxEditor instance is only an issue when working with dark themes.  We discuss working with dark themes in the following help topic:


If you don't want to have to set BackColor and ForeColor, you can alternatively define appropriate colors for the "Plain Text" style instead of keeping the default null values.  The same topic has a section that discusses how to configure the "Plain Text" style.

Actipro Software Support

Add Comment

Please log in to a validated account to post comments.