ComponentOne XmlEditor for WinForms: XmlEditor for WinForms Task-Based Help > Creating a Custom ToolStrip

Creating a Custom ToolStrip

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

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

using C1.Win.XmlEditor;

using C1.Win.XmlEditor.ToolStrips;

 

 

namespace C1XmlEditorCustomToolStrip

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

         public enum CommandButton

    {

        Cut,

        Copy,

        Paste

    }

 

        public class MyToolStrip : XmlEditorToolStripBase

        {

            protected override void OnInitialize()

            {

                AddButton(C1.Win.XmlEditor.ToolStrips.CommandButton.Cut);

                AddButton(C1.Win.XmlEditor.ToolStrips.CommandButton.Copy);

                AddButton(C1.Win.XmlEditor.ToolStrips.CommandButton.Paste);

            }

        }

 

  public class XmlEditorToolStripButton : ToolStripButton

        {

            public C1XmlEditor 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 = c1XmlEditor1;

        }

    }

}


Send comments about this topic to ComponentOne.
Copyright © 1987-2009 ComponentOne LLC. All rights reserved.