ClassRadSyntaxEditor
A control for editing source code with syntax highlighting and advanced text editing capabilities.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.SyntaxEditor.dll
Syntax:
[TelerikToolboxCategory("Editors")]
[Docking(DockingBehavior.Ask)]
public class RadSyntaxEditor : RadControl, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, INotifyPropertyChanged, ISupportInitializeNotification, ISupportInitialize, IComponentTreeHandler, ILayoutHandler, IAnalyticsProvider
Inheritance: objectMarshalByRefObjectComponentControlScrollableControlRadControlRadSyntaxEditor
Implements:
Inherited Members
Constructors
RadSyntaxEditor()
Declaration
public RadSyntaxEditor()
Properties
AllowScaling
Gets or sets a value indicating whether text scaling is allowed in the editor.
Declaration
[Browsable(true)]
public bool AllowScaling { get; set; }
Property Value
CaretColor
Gets or sets the color of the text cursor (caret) in the editor.
Declaration
[Browsable(true)]
public Color CaretColor { get; set; }
Property Value
CaretDisplayMode
Gets or sets the display mode of the text cursor (caret), determining its appearance in the editor.
Declaration
[Browsable(true)]
public CaretDisplayMode CaretDisplayMode { get; set; }
Property Value
CaretWidth
Gets or sets the width of the text cursor (caret) when the CaretDisplayMode is set to Normal.
Declaration
[Browsable(true)]
public double CaretWidth { get; set; }
Property Value
Commands
Gets the collection of commands that can be executed in the syntax editor.
Declaration
[Browsable(false)]
public SyntaxEditorCommands Commands { get; }
Property Value
DefaultSize
Gets the default size of the control when it is initially placed on a design surface.
Dispatcher
Gets the dispatcher object that manages the execution of operations on the UI thread.
Declaration
[Browsable(false)]
public Dispatcher Dispatcher { get; }
Property Value
Document
Gets or sets the text document that contains the content displayed and edited in the control.
Declaration
[Browsable(false)]
public TextDocument Document { get; set; }
Property Value
EditorFontSize
Gets or sets the font size of the text displayed in the editor.
Declaration
[Browsable(true)]
public double EditorFontSize { get; set; }
Property Value
InputHandler
Gets or sets the component which is responsible for handling the keyboard and mouse input of the RadSyntaxEditor.
Declaration
public SyntaxEditorInputBehavior InputHandler { get; set; }
Property Value
IsCaretVisible
Gets or sets a value indicating whether the text cursor (caret) is visible in the editor.
Declaration
[Browsable(true)]
public bool IsCaretVisible { get; set; }
Property Value
IsSelectionEnabled
Gets or sets a value indicating whether text selection is enabled in the editor.
Declaration
[Browsable(true)]
public bool IsSelectionEnabled { get; set; }
Property Value
IsWordWrapEnabled
Gets or sets a value indicating whether word wrapping is enabled in the editor.
Declaration
[Browsable(true)]
public bool IsWordWrapEnabled { get; set; }
Property Value
Palette
Gets or sets the color palette that defines the appearance of syntax elements in the editor.
Declaration
[Browsable(false)]
public SyntaxEditorPalette Palette { get; set; }
Property Value
ScaleFactor
Gets or sets the scale factor that determines the size of text and UI elements in the editor.
Declaration
[Browsable(true)]
public double ScaleFactor { get; set; }
Property Value
ShouldTaggersProcessEntireLines
Gets or sets a value indicating whether the entire line should be processed by the syntax taggers instead of just the modified region.
Declaration
[Browsable(true)]
public bool ShouldTaggersProcessEntireLines { get; set; }
Property Value
ShowLineNumbers
Gets or sets a value indicating whether the line numbers are shown.
Declaration
[Browsable(true)]
public bool ShowLineNumbers { get; set; }
Property Value
true if the line numbers are shown; otherwise, false.
SyntaxEditorElement
Gets the RadSyntaxEditorElement which is the main element in the control.
Declaration
[Browsable(false)]
public RadSyntaxEditorElement SyntaxEditorElement { get; }
Property Value
TaggersRegistry
Gets the registry of taggers that provide syntax highlighting and other text analysis features.
Declaration
[Browsable(false)]
public TaggersRegistry TaggersRegistry { get; }
Property Value
TextFormatDefinitions
Gets the stack of text format definitions that determine how different elements of text are displayed.
Declaration
[Browsable(false)]
public TextFormatDefinitionStack TextFormatDefinitions { get; }
Property Value
UseShiftKeyInSelection
Gets or sets a value indicating whether the Shift key must be used to extend text selection.
Declaration
[Browsable(true)]
public bool UseShiftKeyInSelection { get; set; }
Property Value
Methods
Copy()
Copies the current text selection to the clipboard.
Declaration
public void Copy()
CreateAccessibilityInstance()
Creates the accessibility object for this control to support screen readers and other assistive technologies.
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
An AccessibleObject that represents the control for accessibility purposes.
Overrides
CreateBehavior()
Creates the input behavior component for the RadSyntaxEditor.
Declaration
protected override ComponentInputBehavior CreateBehavior()
Returns
A new instance of RadSyntaxEditorComponentInputBehavior for handling input in this control.
Overrides
CreateChildItems(RadElement)
Creates the child elements of the RadSyntaxEditor control.
Declaration
protected override void CreateChildItems(RadElement parent)
Parameters
parent
The parent element to which child elements will be added.
Overrides
GetPointFromPosition(CaretPosition)
Converts a text caret position to a point in the editor's coordinate system.
Declaration
public Point GetPointFromPosition(CaretPosition position)
Parameters
position
The caret position to convert.
Returns
A Point representing the visual position of the caret.
GetPositionFromControlPoint(Point)
Converts a point in the control's coordinate system to a text caret position.
Declaration
public CaretPosition GetPositionFromControlPoint(Point point)
Parameters
point
The point relative to the control's top-left corner.
Returns
A CaretPosition representing the text position at the specified point.
IsInputKey(Keys)
Determines whether a key should be processed as an input key or passed to the parent control.
MoveCurrentLineToTop()
Scrolls the editor to position the current line at the top of the viewport.
Declaration
public void MoveCurrentLineToTop()
OnGotFocus(EventArgs)
Handles the event that occurs when the control gets focus, showing the text cursor and focusing the editor element.
OnKeyDown(KeyEventArgs)
Handles the key down event by delegating it to the input handler.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
e
The event data containing information about the key.
Overrides
OnKeyPress(KeyPressEventArgs)
Handles the key press event by delegating it to the input handler.
Declaration
protected override void OnKeyPress(KeyPressEventArgs e)
Parameters
e
The event data containing information about the pressed key.
Overrides
OnKeyUp(KeyEventArgs)
Handles the key up event by delegating it to the input handler.
Declaration
protected override void OnKeyUp(KeyEventArgs e)
Parameters
e
The event data containing information about the released key.
Overrides
OnLoad(Size)
Called when the control is loaded to initialize the editor element.
Declaration
protected override void OnLoad(Size desiredSize)
Parameters
desiredSize
The desired size of the control.
Overrides
OnLostFocus(EventArgs)
Handles the event that occurs when the control loses focus, hiding the text cursor.
OnThemeChanged()
Called when the control's theme changes to update visual elements accordingly.
Declaration
protected override void OnThemeChanged()
Overrides
PageDown()
Scrolls the editor content down by one page (viewport height).
Declaration
public void PageDown()
PageUp()
Scrolls the editor content up by one page (viewport height).
Declaration
public void PageUp()
ProcessDialogChar(char)
Processes a dialog character, allowing Alt key combinations to be handled by dialogs.
ProcessMnemonic(char)
Processes a mnemonic character, which the editor does not support.
ScaleControl(SizeF, BoundsSpecified)
Scales the control and its child elements according to the specified scaling factor.
Declaration
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
Parameters
factor
The scaling factor to apply.
specified
A value indicating which bounds of the control to scale.
Overrides
UpdateSelection()
Refreshes the visual representation of the current text selection in the editor.
Declaration
public void UpdateSelection()
ZoomIn()
Increases the zoom level (scale factor) of the editor by one step.
Declaration
public void ZoomIn()
ZoomOut()
Decreases the zoom level (scale factor) of the editor by one step.
Declaration
public void ZoomOut()
ZoomTo(double)
Sets the editor to a specific zoom level (scale factor). The minimum supported zoom level is 0.2 and the maximum supported is 4.
Declaration
public void ZoomTo(double zoomLevel)
Parameters
zoomLevel
The scale factor to be applied to the editor content.
Exceptions
Thrown when the zoomLevel parameter is negative.
Events
CommandError
Occurs when a command execution results in an error.
Declaration
public event EventHandler<CommandErrorEventArgs> CommandError
Event Value
CommandExecuted
Occurs after a command has been successfully executed.
Declaration
public event EventHandler<CommandExecutedEventArgs> CommandExecuted
Event Value
CommandExecuting
Occurs before a command is executed, allowing you to cancel or modify the command execution.
Declaration
public event EventHandler<CommandExecutingEventArgs> CommandExecuting
Event Value
DocumentChanged
Occurs after the document has been changed, such as when a new document is loaded or created.
DocumentChanging
Occurs before the document is changed, allowing you to perform actions before a new document is loaded.
DocumentContentChanged
Occurs after the text content of the document has been modified, providing information about the changes made.
Declaration
public event EventHandler<TextContentChangedEventArgs> DocumentContentChanged
Event Value
DocumentContentChanging
Occurs before the text content of the document is modified, allowing you to cancel or modify the changes.
Declaration
public event EventHandler<TextContentChangingEventArgs> DocumentContentChanging
Event Value
IsReadOnlyChanged
Occurs when the read-only state of the editor changes.
LayoutPropertiesChanged
Occurs when the layout properties of the editor change, affecting how text is displayed.
Declaration
public event EventHandler LayoutPropertiesChanged
Event Value
PreviewSyntaxEditorInput
Occurs before text input is processed by the syntax editor, allowing you to intercept and modify the input.
Declaration
public event EventHandler<PreviewSyntaxEditorInputEventArgs> PreviewSyntaxEditorInput
Event Value
PreviewSyntaxEditorKeyDown
Occurs before a key down event is processed by the syntax editor, allowing you to intercept and handle keyboard input.
Declaration
public event EventHandler<PreviewSyntaxEditorKeyEventArgs> PreviewSyntaxEditorKeyDown
Event Value
PreviewSyntaxEditorKeyUp
Occurs before a key up event is processed by the syntax editor, allowing you to intercept and handle keyboard input.
Declaration
public event EventHandler<PreviewSyntaxEditorKeyEventArgs> PreviewSyntaxEditorKeyUp
Event Value
PreviewSyntaxEditorMouseLeftButtonDown
Occurs before a mouse left button down event is processed by the syntax editor, allowing you to intercept and handle mouse input.
Declaration
public event EventHandler<PreviewSyntaxEditorMouseButtonEventArgs> PreviewSyntaxEditorMouseLeftButtonDown
Event Value
PreviewSyntaxEditorMouseRightButtonDown
Occurs before a mouse right button down event is processed by the syntax editor, allowing you to intercept and handle context menu actions.
Declaration
public event EventHandler<PreviewSyntaxEditorMouseButtonEventArgs> PreviewSyntaxEditorMouseRightButtonDown
Event Value
ScaleFactorChanged
Occurs when the scaling factor of the editor changes, affecting the size of text and UI elements.
SelectionChanged
Occurs when the text selection in the editor changes, either by user interaction or programmatically.
ViewportChanged
Occurs when the visible area (viewport) of the editor changes, such as during scrolling or resizing.