Editor for WinForms | ComponentOne
C1.Win.C1Editor.4.5.2 Assembly / C1.Win.C1Editor Namespace / C1Editor Class / CanPasteAsText Property
Example

In This Topic
    CanPasteAsText Property
    In This Topic
    Determines whether you can paste information from the Clipboard in text format.
    Syntax
    'Declaration
     
    Public ReadOnly Property CanPasteAsText As System.Boolean
    public System.bool CanPasteAsText {get;}
    Example
    This example shows how to create a custom context menu that can be linked to a C1Editor control and has Cut, Copy and Paste buttons.
    class MyContextMenuStrip : ContextMenuStrip
    {
        private C1Editor _owner;
        private ToolStripMenuItem _btnCut, _btnCopy, _btnPaste;
                
        public MyContextMenuStrip(C1Editor editor)
        {
            // save reference to parent control
            _owner = editor;
                
            // create menu items
            _btnCut = (ToolStripMenuItem)Items.Add("Cut");
            _btnCut.ShortcutKeys = Keys.Control | Keys.X;
            _btnCopy = (ToolStripMenuItem)Items.Add("Copy");
            _btnCopy.ShortcutKeys = Keys.Control | Keys.C;
            _btnPaste = (ToolStripMenuItem)Items.Add("Paste");
            _btnPaste.ShortcutKeys = Keys.Control | Keys.V;
        }
                
        protected override void OnItemClicked(ToolStripItemClickedEventArgs e)
        {
            // close menu (not automatic)
            Close();
                
            if (e.ClickedItem == _btnCopy)
                _owner.Copy();
            else if (e.ClickedItem == _btnCut)
                _owner.Cut();
            else if (e.ClickedItem == _btnPaste)
                _owner.Paste();
            // on to base class
            base.OnItemClicked(e);
        }
                
        protected override void OnOpening(System.ComponentModel.CancelEventArgs e)
        {
            if (_owner.Mode == EditorMode.Preview)
            {
                e.Cancel = true;
            }
            else if (_owner.Mode == EditorMode.Source)
            {
               _btnCopy.Enabled = _owner.CanCopy;
               _btnCut.Enabled = _owner.CanCut;
               _btnPaste.Enabled = _owner.CanPaste || _owner.CanPasteAsText;
                
            // on to base class
            base.OnOpening(e);
            }
       }
    See Also