Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.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# ICSharpCode.TextEditor-按键关闭问题_C#_Autocomplete_Icsharpcode - Fatal编程技术网

C# ICSharpCode.TextEditor-按键关闭问题

C# ICSharpCode.TextEditor-按键关闭问题,c#,autocomplete,icsharpcode,C#,Autocomplete,Icsharpcode,我正在尝试为ICSharpCode.TextEditor创建一个自动完成函数。 但是fileTabs\u键不识别Enter/Backspace/Tab/ 我试图向活动编辑器添加一个新的KeyEventHandler,但它没有调用我的KeyDown函数 也许我可以直接请求windows消息,但我不知道怎么做,因为每个人都只使用e.KeyDown或e.KeyPress事件 请帮助…ICSharpCode.TextEditor是一个复合控件。如果将事件处理程序附加到主文本编辑器,则不会收到任何事件。您

我正在尝试为ICSharpCode.TextEditor创建一个自动完成函数。 但是fileTabs\u键不识别Enter/Backspace/Tab/

我试图向活动编辑器添加一个新的KeyEventHandler,但它没有调用我的KeyDown函数

也许我可以直接请求windows消息,但我不知道怎么做,因为每个人都只使用e.KeyDown或e.KeyPress事件


请帮助…

ICSharpCode.TextEditor是一个复合控件。如果将事件处理程序附加到主文本编辑器,则不会收到任何事件。您必须附加到textEditor.ActiveTextAreaControl.TextArea上的事件


此外,文本编辑器本身已经在处理事件。要截获按键,请使用特殊的事件textEditor.ActiveTextAreaControl.TextArea.KeyEventHandler。

当按下Enter/Backspace/Tab键时,不要触发KeyPress、KeyDown和KeyEventHandler
要捕获这些按键,必须处理KeyUp事件。

然后,您可以检查KeyEventArgs.KeyCode的值,正如Daniel所说,您可以使用“ActiveTextAreaControl.TextArea”事件来捕获键,如Enter、空格和组合,您使用的代码如下所示,其中我捕获的是CTRL+空格组合:

public frmConexon()
    {
        InitializeComponent();
        this.txtEditor.ActiveTextAreaControl.TextArea.KeyUp += new System.Windows.Forms.KeyEventHandler(TextArea_KeyUp);
    }

    void TextArea_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Space && e.Control)
        {
            TextArea S = (TextArea)sender;
            MessageBox.Show(string.Format("CTRL + Spacio ({0})", S.Caret.ScreenPosition.ToString()));
        }
    }

在这个例子中,我甚至检索插入符号的屏幕坐标,因为我想在那里显示一个弹出窗口。

我通过获取KeyStates解决了这个问题。请提供您的解决方案作为答案,以便其他人在遇到这个问题时也能轻松找到它。@zee您是如何做到的,您能提供答案吗?谢谢Daniel,这几天你帮了我一个大忙!