Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Winforms,闪烁-保存快捷方式插入';s';致编辑的信_C#_Winforms_Shortcut_Scintilla - Fatal编程技术网

C# Winforms,闪烁-保存快捷方式插入';s';致编辑的信

C# Winforms,闪烁-保存快捷方式插入';s';致编辑的信,c#,winforms,shortcut,scintilla,C#,Winforms,Shortcut,Scintilla,我编写了用于编辑sql过程的小应用程序,并使用了强大的代码编辑器控件。我定义了用于保存文件的Ctrl+S快捷方式: protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.Control | Keys.S)) { saveToolStripButton_Click(this.saveToolStripButton, null);

我编写了用于编辑sql过程的小应用程序,并使用了强大的代码编辑器控件。我定义了用于保存文件的Ctrl+S快捷方式:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    if (keyData == (Keys.Control | Keys.S))
    {
            saveToolStripButton_Click(this.saveToolStripButton, null);
    }
    else if (keyData == (Keys.Control | Keys.O))
            openToolStripButton_Click(this.openToolStripButton, null);
    else if (keyData == (Keys.Control | Keys.N))
            newToolStripButton_Click(this.newToolStripButton, null);
    else if (keyData == (Keys.Control | Keys.W))
    {
            if (this.tabControl2.SelectedTab != null)
                    (this.tabControl2.SelectedTab as WorkspaceControl).closeSelectedFile();
    }

    return base.ProcessCmdKey(ref msg, keyData);
}
当我只是重新保存旧文件时,一切正常,但当它的“新文件-保存文件后”对话框关闭并且文件已保存时,字母“s”将添加到编辑器的末尾。如何防止它?

添加“s”是因为即使不需要它,也会调用
base.ProcessCmdKey


如果要阻止进一步处理击键,请确保在适当的情况下返回
true

您可以使用
key\u down
闪烁控制事件:

    private void scintilla_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.S && e.Control)
        {
            // Saving ...
            e.SuppressKeyPress = true;
        }
    }

非常感谢。很简单,很有帮助。