WinForms property reference

Documentation index · Methods · Enums

All members are in CODE.Editor.WinForms. TextEditor is a sealed UserControl. The following tables cover its editor-specific properties; ordinary inherited WinForms layout properties such as Dock, Size, and Visible retain their normal meanings.

State and initialization

Property Type/default Meaning
EditorText string, empty Cached serialized value; assignment queues a load after initialization
Options Read-only EditorOptions instance Mutable settings object, exposed for designer expansion
IsReady Read-only bool Successful browser/editor initialization
IsDirty Read-only bool Last confirmed dirty state
Revision Read-only int Last confirmed model revision
SessionId Read-only string Current session identifier
Selection Read-only EditorSelection Last confirmed flat selection
LastError Read-only nullable Exception Last reported control error
UserDataFolder Nullable string WebView2 profile folder; set before initialization
LocalImageFolder Nullable string Folder mapped to TextEditor.LocalImageOrigin; set before initialization

LocalImageOrigin is a public constant: https://code-editor-assets.example. Mapping a folder does not save images; provide an import event handler. Set pre-initialization properties before adding/showing the control if that could create its handle.

Document and view

These settings are available both directly on the control and on Options.

Property Type/default JavaScript key Meaning
Format EditorFormat.Markdown format Stored representation
ViewMode EditorViewMode.Visual mode Source/Visual experience
Language EditorLanguage.Markdown language Source coloring/comments
ReadOnly false readOnly Prevent editing
WordWrap true wrap Source wrapping
LineNumbers true lineNumbers Source gutter
SyntaxHighlighting true decorated Lexical decoration
TabWidth 4 tabWidth Fallback width; valid values 2, 4, 8. JSON, HTML/XML, and YAML default to 2.
LanguageIndentation empty map languageIndentation Per-language width overrides, e.g. { "json": 4 }; assign a new dictionary to apply changes.
SnippetFormatActions null (four defaults) snippetFormatActions Ordered SnippetFormatAction[]; customize IDs, labels, purposes, and order. [] hides format items, null restores defaults.
IndentWithTabs false indentWithTabs Tabs versus spaces
TabIndents true tabIndents Tab editing interaction
TypingRules true typingRules Visual input shortcuts

Setting Format to PlainText forces Source; RichJson forces Visual. Incompatible explicit ViewMode assignments throw. To load a new document atomically with format/view/language, use LoadAsync. To convert an existing document, use ConvertFormatAsync.

Presentation and preview

Property Type/default JavaScript key Meaning
Theme EditorTheme.Light theme Light/dark presentation
DisplayFontFamily "Segoe UI, sans-serif" fontFamily Visual editing surface CSS font family; Source uses --ce-source-font-family
DisplayFontSize 16 fontSize CSS pixels, 10–48
Placeholder Empty string placeholder Empty-content hint
AccessibleLabel "Text editor" label Accessibility label
PreviewVisible false Host preview visibility Show optional pane
PreviewSync true previewSync Follow editor scroll/caret
PreviewSplit 0.5 previewSplit Editor's share, finite 0.2–0.8; layout may impose tighter visual limits
PreviewCss Empty string previewCss Stylesheet text isolated to preview
PreviewSyntaxHighlighting true previewSyntaxHighlighting Highlight code snippets in the generated preview, independently of editing syntax highlighting; updates live.
FindEnabled true Control-shell option Enable internal find UI
ReplaceEnabled true Control-shell option Enable replacement UI

Display fonts do not change document formatting. Use content-formatting methods for stored rich styles. PreviewCss is separate from both. When the user resizes the divider, PreviewSplit is updated and PreviewResized fires.

Policy and image settings

Property Type/default JavaScript key Meaning
Preset EditorPreset.Full preset Starting feature policy
AllowEmbeddedHtml true allowEmbeddedHtml Supported HTML extensions in Markdown
AllowSourceView true allowSourceView Source access
UnsupportedContent UnsupportedContentHandling.Preserve unsupportedContent Preserve/reject/convert
MaxListDepth 8 maxListDepth Allowed nesting 0–8
AllowRemoteImages false allowRemoteImages Broad HTTP(S) image display
ExternalImages ExternalImageHandling.Reference externalImages Pasted reference handling
MaxImageBytes 10485760 maxImageBytes Per-file bytes, allowed 1–104857600

Collection settings on Options

These do not have additional direct TextEditor forwarding properties:

Member Default and rules
Options.HeadingLevels int[] of 1–6; duplicates removed; values outside 1–6 rejected; empty allowed
Options.ImageOrigins Empty string[]; exact absolute HTTP(S) origins with no path or trailing slash
Options.ImageTypes PNG/JPEG/GIF/WebP MIME strings; unsupported MIME values rejected
Options.Features Read-only dictionary of explicitly assigned EditorFeature overrides
Options.SetFeature(feature, enabled) Add/change a feature override
Options.ResetFeatures() Clear explicit overrides
Options.PropertyChanged INotifyPropertyChanged notification for setting changes
Options.ToString() Human-readable format/view description, useful in designer UI

Array getters return copies. Reassign an edited array rather than modifying a retrieved array and expecting live updates. Features is the override set; GetCapabilitiesAsync returns the effective policy after preset and format restrictions.

Update semantics

Use the owning UI thread. Settings changed before initialization form startup configuration; later changes are sent through the operation queue. Local range/enum checks throw synchronously, while browser policy/configuration checks may fail asynchronously and report through EditorError. A property can therefore hold a requested setting that the browser has not yet accepted. FlushAsync helps await queued work, and capability/snapshot queries establish accepted state.

Avoid a sequence of temporarily incompatible policy settings on a loaded document. Configure before loading where possible. Policy changes reset undo/redo. Empty DisplayFontFamily, Placeholder, and AccessibleLabel values clear the corresponding browser display override.

Options.MaxDocumentLength defaults to 0 (unlimited). Options.HistoryLimitBytes defaults to 33,554,432 (estimated snapshot budget; 0 disables it). Options.UnlockImageAspectRatio defaults to false. EditorLanguage exposes 195 catalog entries: 193 bundled highlight.js grammars, VisualFoxPro, and separate HTML/XML selections sharing a grammar. See chapter 20.

Options.UITheme is an EditorUITheme record with Palette, Variables and Css. It works before initialization and can be replaced at runtime. This styles the editing UI and its portals, separately from PreviewCss and stored content formatting. Styling guide.

Options.UIStrings accepts EditorUIStrings(Locale, Values) for shared UI wording and native search. Assign a new record to notify the control. See UI wording and localization.

Appearance (also Options.Appearance) is an expandable group of native color, font and spacing overrides. Nested changes apply live. See host appearance settings for the full property list and Olympus theme mapping example. ImageToolbar / Options.ImageToolbar accepts EditorImageToolbarOptions to configure Size, Replace, AlternativeText, Actions and InlineActions in Visual image toolbars. See image toolbar configuration. Image colors are exposed through Appearance.ImageToolbarBackground, ImageToolbarForeground, hover/pressed background and foreground, ImageSelectionColor, ImageSizeBackground and ImageSizeForeground.

Native spellcheck

SpellCheck (default true) is available on both TextEditor and Options and can change at runtime. It enables the Edge/Windows spell checker for prose and excludes code snippets, inline code, and programming-language Source views.

TextEditor.SpellCheckLanguage (default empty, runtime language) must be set before initializing or showing the control. WebView2 chooses its native proofing language at environment startup; changing the HTML language alone does not reliably change its dictionary. Use a new control/environment to choose another native language. Examples include English (en-US, en-GB), German (de-DE), Spanish (es-ES), French (fr-FR), Italian (it-IT), Dutch (nl-NL), and Portuguese (pt-PT); dictionary availability depends on Edge/Windows and installed language support.

var editor = new TextEditor {
    Dock = DockStyle.Fill,
    SpellCheckLanguage = "de-DE",
    SpellCheck = true
};
Controls.Add(editor);

Default profile folders are separated by explicit language so controls using different environment languages do not conflict. When specifying UserDataFolder yourself, use distinct folders for different environment languages. Added words are stored by Edge/Windows in its profile/dictionary, not in the document or review sidecar. The editor does not maintain dictionaries.

Right-click a misspelled word for Edge's native corrections and available dictionary/ignore commands. The native menu also keeps basic editing commands. Inspect remains available only while a debugger is attached; spelling works in release builds. Some native dictionary commands differ by runtime/OS. There is no custom hover spelling UI.

Preview splitter colors and runtime themes

Use editor.Appearance.PreviewSplitterBackground, PreviewSplitterForeground (grip), PreviewSplitterHoverBackground, PreviewSplitterHoverForeground, PreviewSplitterActiveBackground, PreviewSplitterActiveForeground (dragging), and PreviewSplitterFocusColor (outline). All are System.Drawing.Color properties; Color.Empty restores defaults.

All Appearance properties, including existing syntax and toolbar colors, update automatically at runtime. Set them in the host theme-change handler. FlushAsync() is only needed when subsequent code must wait for the WebView to finish applying changes.

// Apply again whenever the host theme changes.
editor.Appearance.PreviewSplitterBackground = Color.FromArgb(40, 40, 40);
editor.Appearance.PreviewSplitterForeground = Color.Silver;
editor.Appearance.PreviewSplitterHoverBackground = Color.DimGray;
editor.Appearance.PreviewSplitterActiveBackground = Color.SteelBlue;
editor.Appearance.PreviewSplitterFocusColor = Color.CornflowerBlue;

The MaximumEditWidth and MaximumPreviewWidth properties default to 900 logical (CSS) pixels and accept positive integers. RestrictMaximumEditWidth and RestrictMaximumPreviewWidth default to true; disable either independently to use the full available pane width. Content is centered when the pane is wider than its limit and shrinks to fit smaller panes. The edit limit applies to Visual and Source modes; WordWrap = false still allows long source lines to scroll horizontally. These settings affect display only, not saved content.