DCSoft.Writer编辑器实现自定义右键菜单

(该文章仅适合使用DCSoft.Writer的伙伴参考)

DCSoft.Writer编辑器(版本1.2014.1217.1)的右键菜单是有点问题的,手上没有最新版本dll,加官方群没有通过,不知道最新版有没有调整右键菜单

主要问题是,默认右键菜单有些是灰色的,比如“粘贴”菜单

原本想的解决方法是在空间的ContextMenuStrip属性改为自建的右键菜单控件,测试无效

查看代码发现,可以修改writerControlExt1.InnerWriterControl.ContextMenuStrip属性

writerControlExt1.InnerWriterControl.ContextMenuStrip = 自建右键菜单

然后就可以愉快的使用自建控件了,附上常用菜单的命令

    Private Sub 重复ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重复ToolStripMenuItem.Click
        writerControlExt1.ExecuteCommand("Redo", False, Nothing)
    End Sub

    Private Sub 撤销ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 撤销ToolStripMenuItem.Click
        writerControlExt1.ExecuteCommand("Undo", False, Nothing)
    End Sub

    Private Sub 剪切ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 剪切ToolStripMenuItem.Click
        writerControlExt1.ExecuteCommand("Cut", False, Nothing)
    End Sub

    Private Sub 复制ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 复制ToolStripMenuItem.Click
        writerControlExt1.ExecuteCommand("Copy", False, Nothing)
    End Sub

    Private Sub 粘贴ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 粘贴ToolStripMenuItem.Click
        writerControlExt1.ExecuteCommand("Paste", False, Nothing)
    End Sub

    Private Sub 删除ToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles 删除ToolStripMenuItem1.Click
        writerControlExt1.ExecuteCommand("Delete", False, Nothing)
    End Sub

    Private Sub 属性ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 属性ToolStripMenuItem.Click
        writerControlExt1.ExecuteCommand("ElementProperties", False, Nothing)
    End Sub

 

posted @ 2020-12-08 16:43  蒲公英C  阅读(632)  评论(0编辑  收藏  举报