Editor for WinForms | ComponentOne
Editor for WinForms Task-Based Help / Creating a Custom ToolStrip
In This Topic
    Creating a Custom ToolStrip
    In This Topic

    You can implement your own toolstrip to use with C1Editor by using the C1EditorToolStripBase as a base class and adding buttons.

    The following code is an example of a toolbar with three buttons: Cut, Copy, and Paste.

    To write code in C#

    C#
    Copy Code
    using C1.Win.C1Editor;
    using C1.Win.C1Editor.ToolStrips;
      
    namespace C1EditorCustomToolStrip
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
              public enum CommandButton
        {
            Cut,
            Copy,
            Paste
        }
             public class MyToolStrip : C1EditorToolStripBase
            {
                protected override void OnInitialize()
                {
                    AddButton(C1.Win.C1Editor.ToolStrips.CommandButton.Cut);
                    AddButton(C1.Win.C1Editor.ToolStrips.CommandButton.Copy);
                    AddButton(C1.Win.C1Editor.ToolStrips.CommandButton.Paste);
                }
            }
       public class C1EditorToolStripButton : ToolStripButton
            {
                public C1Editor Editor { get; set; }
                public CommandButton Command { get; set; }
            }
             private void Form1_Load(object sender, EventArgs e)
            {
                // Using MyToolStrip in an application:
     
                MyToolStrip toolStrip = new MyToolStrip();
                this.Controls.Add(toolStrip);
                toolStrip.Editor = c1Editor1;
            }
        }
    }