ZidUtilities.CommonCode.ICSharpTextEditor 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZidUtilities.CommonCode.ICSharpTextEditor --version 1.0.1
                    
NuGet\Install-Package ZidUtilities.CommonCode.ICSharpTextEditor -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZidUtilities.CommonCode.ICSharpTextEditor" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZidUtilities.CommonCode.ICSharpTextEditor" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ZidUtilities.CommonCode.ICSharpTextEditor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZidUtilities.CommonCode.ICSharpTextEditor --version 1.0.1
                    
#r "nuget: ZidUtilities.CommonCode.ICSharpTextEditor, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZidUtilities.CommonCode.ICSharpTextEditor@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZidUtilities.CommonCode.ICSharpTextEditor&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ZidUtilities.CommonCode.ICSharpTextEditor&version=1.0.1
                    
Install as a Cake Tool

CommonCode.ICSharpTextEditor

Extended text editor control based on ICSharpCode.TextEditor with advanced syntax highlighting and editing features.

Features

By default this control provides syntax highlight for a good number of the languages, the syntax is based on the xshd files provided by this github repository: https://github.com/xv/ICSharpCode.TextEditor-Lexers Except for TransactSQL which has been custom made for this library.

To use the syntax highlighting features you need to set the Syntax property of the ExtendedEditor control to one of the predefined syntax types. The control also provides code folding and bracket matching depending on the language selected.

Also there is a toolbar with expected functionality, comment, uncomment, toggle bookmark, etc. to access to this features search for the preperties type ToolbarOption in the ExtendedEditor control, you can work with them on the designer. Buttons Run, Stop and Kill, do not provide functionality by default, you need to handle them using the control's events: OnRun, OnStop and OnKill.

The toolbar can be also customized with shortcuts, look at the class ToolbarOption and its properties ShortCut and ThenShortCut. Finally the control also provide implicit shortcuts for common operations, selection to uppercase, lowercase, etc. Look at the class ImplicitShortcut for more information.

The original ICSharpCode.TextEditor.TextEditorControl can be accessed through the propety Editor of the ExtendedEditor control.

These functionlity satisfy most of MY needs, I might come back and change or add more features in the future, but for now this is it.

Extended Editor Control

  • ExtendedEditor: Enhanced text editor with toolbar and extended functionality
  • Custom icon and designer support for Windows Forms integration

Syntax Highlighting

  • SyntaxHighlighting: Advanced syntax highlighting system
  • InlineSyntaxProvider: Dynamic syntax provider for runtime syntax definitions
  • SyntaxFiles: Embedded syntax definition resources
  • Support for multiple programming languages

Code Folding

  • FoldingStrategies: Code folding strategies for different languages
  • Collapsible code regions for improved readability

Bracket Matching

  • BracketMatching: Automatic bracket and parenthesis matching
  • Visual highlighting of matching pairs

Helper Forms

  • Additional dialogs and forms for editor enhancement
  • Context-sensitive helper interfaces

Additional Features

  • ICSharpTextEditorExtensions: Extension methods for the editor
  • ImplicitShortcut: Keyboard shortcut management
  • ToolbarOption: Customizable toolbar options
  • ToolbarTextBox: Specialized toolbar text box control

Dependencies

  • ICSharpCode.TextEditor
  • System.Windows.Forms

Target Framework

.NET Framework 4.8

Installation

Add a reference to CommonCode.ICSharpTextEditor.dll in your Windows Forms project. The ICSharpCode.TextEditor component is included.

Usage Examples

Basic Integration in Windows Forms

using ZidUtilities.CommonCode.ICSharpTextEditor;

// Add ExtendedEditor to your form
var codeEditor = new ExtendedEditor
{
    Dock = DockStyle.Fill,
    ShowLineNumbers = true
};

this.Controls.Add(codeEditor);

Syntax Highlighting

using ICSharpCode.TextEditor.Document;

// Set syntax highlighting based on file extension
extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.CSharp;


// Set highlighting dynamically
string extension = Path.GetExtension(fileName).ToLower();
switch (extension)
{
    case ".cs":
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.CSharp;
        break;
    case ".vb":
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.VBNET;
        break;
    case ".xml":
    case ".config":
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.XML;
        break;
    case ".html":
    case ".htm":
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.HTML;
        break;
    case ".js":
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.JavaScript;
        break;
    case ".java":
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.Java;
        break;
    case ".cpp":
    case ".h":
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.CPlusPlus;
        break;
    case ".sql":
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.TransactSQL;
        break;
    default:
        extendedEditor.Syntax = ZidUtilities.CommonCode.ICSharpTextEditor.SyntaxHighlighting.None;
        break;
}

Text Selection and Manipulation

// Get selected text
string selectedText = codeEditor.ActiveTextAreaControl.SelectionManager.SelectedText;

// Replace selected text
codeEditor.ActiveTextAreaControl.SelectionManager.SelectedText = "replacement";

// Select all
codeEditor.ActiveTextAreaControl.SelectAll();

// Get current line
int lineNumber = codeEditor.ActiveTextAreaControl.Caret.Line;
string lineText = codeEditor.Document.GetText(codeEditor.Document.GetLineSegment(lineNumber));

// Insert text at caret
int offset = codeEditor.ActiveTextAreaControl.Caret.Offset;
codeEditor.Document.Insert(offset, "inserted text");

// Clear all text
codeEditor.Text = string.Empty;

Search and Replace

Use the provide search functionality in the toolbar or implement custom search using the editor's document methods.

Complete Example: Simple Code Editor

public class SimpleCodeEditor : Form
{
    private ExtendedEditor codeEditor;
    private string currentFile;

    public SimpleCodeEditor()
    {
        InitializeComponents();
    }

    private void InitializeComponents()
    {
        this.Text = "Simple Code Editor";
        this.Size = new Size(800, 600);

        // Create editor
        //Dont do this, use visual studio designer to add the control to the form, makes everythign easier
        //codeEditor = new ExtendedEditor
        //{
        //    Dock = DockStyle.Fill,
        //    ShowLineNumbers = true
        //};

        //By default open file functionality is included in the toolbar
        //var openItem = new ToolStripMenuItem("Open", null, OpenFile_Click);
        //By default save file functionality is included in the toolbar
        //var saveItem = new ToolStripMenuItem("Save", null, SaveFile_Click);
    }


}

Common Use Cases

  • Code Editors - Build custom IDEs for Windows Forms
  • Script Editors - Edit SQL, PowerShell, Python scripts
  • Configuration Editors - Edit XML, JSON configuration files
  • Log Viewers - View code or log files with syntax highlighting
  • Source Code Viewers - Display source code in applications
  • Learning Tools - Create programming tutorial applications
  • Text Processing Tools - Advanced text editing with code awareness

Features Summary

  • Syntax Highlighting - Support for 20+ programming languages
  • Code Folding - Collapsible code regions
  • Bracket Matching - Automatic matching bracket highlighting
  • Line Numbers - Optional line number display
  • Undo/Redo - Full undo stack support
  • Search and Replace - Built-in text search functionality
  • Customizable Toolbar - Extensible toolbar with common operations
  • Plugin Architecture - Extend with custom plugins
  • Keyboard Shortcuts - Customizable key bindings
  • CommonCode.AvalonEdit: WPF-based text editor (for WPF applications), which for now is work in progress, no code has been uploaded yet.

Note

This library is specifically for Windows Forms applications. For WPF applications, use CommonCode.AvalonEdit instead.

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ZidUtilities.CommonCode.ICSharpTextEditor:

Package Downloads
ZidUtilities.CommonCode.Win

Custom controls for winforms projects. ThemeManager, Grid, Toast Notifications, BreadCrumb Bar, Diff Viewers, etc.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8 75 12/12/2025
1.0.7 418 12/10/2025
1.0.6 655 12/3/2025
1.0.5 651 12/3/2025
1.0.4 652 12/3/2025
1.0.3 654 12/3/2025
1.0.2 649 12/3/2025
1.0.1 651 12/2/2025
1.0.0 658 12/2/2025

Changed references, to point to nuget package instead of local project.