【问题标题】:AvalonEdit insert text doesnt workAvalonEdit 插入文本不起作用
【发布时间】:2013-09-29 09:38:31
【问题描述】:

我无法在 AvalonEdit TextEditor 中插入字符。

void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
    {
        if (e.Text == "{" || e.Text == "(" || e.Text == "[" || e.Text == "\"" || e.Text == "\'")
        {
            switch (e.Text)
            {
                case "{":
                    int i = editor.TextArea.Caret.Offset;
                    editor.Text.Insert(i, "}");
                    break;
                case "(":
                    editor.Text.Insert(editor.CaretOffset, ")");
                    break;
                case "[":
                    editor.Text.Insert(editor.CaretOffset, "]");
                    break;
                case "\"":
                    editor.Text.Insert(editor.CaretOffset, "\"");
                    break;
                case "\'":
                    editor.Text.Insert(editor.CaretOffset, "\'");
                    break;
            }
        }
    }

我不知道为什么它不起作用。请帮帮我。

【问题讨论】:

    标签: c# text avalondock avalonedit icsharpcode


    【解决方案1】:

    试试这个:

       editor.Document.Insert(editor.TextArea.Caret.Offset, "\'");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-28
      • 2013-01-29
      • 1970-01-01
      • 2014-04-12
      • 1970-01-01
      相关资源
      最近更新 更多