【问题标题】:Syncfusion - No Space-Char after pressing shortcuts "CTRL" + "SPACE"Syncfusion - 按下快捷键“CTRL”+“SPACE”后没有空格字符
【发布时间】:2016-10-13 21:06:26
【问题描述】:

我们正在使用 Syncfusion 框架 Essential Studio 中的 EditControl(工具箱中的组件)来编写一个小型代码编辑器。 我们希望在按下快捷键 CTRL + SPACE 后弹出自动完成窗口,而不在 EditorWindow 中输入空格字符。

有没有办法禁止在 EditControl 中输入字符?

Private Sub editControl1_KeyDown(sender As Object, e As KeyEventArgs)
        If e.Control Then
        ' Do something here
            If e.KeyCode = Keys.Space Then
                EditControl1.ShowContextChoice()
                Dim context = EditControl1.ContextChoiceController
                For Each item As IConfigLexem In lexeme
                    context.Items.Add((item).BeginBlock, CStr(m_MethodComments(item.ID)), Me.EditControl1.ContextChoiceController.Images("Image" & item.FormatName))
                Next
            End If
        End If
    End Sub

【问题讨论】:

  • 你试过e.Handled = true吗?

标签: winforms autocomplete event-handling syncfusion editcontrol


【解决方案1】:

您可以在控件中设置键绑定,这将防止您需要捕获KeyDown 事件。

例如,创建一些 Sub 来配置控件的属性(在我的示例中称为 Editor)并添加以下行:

AddHandler Editor.Commands.Add("Editor.ContextChoice").ProcessCommand, AddressOf Editor.ShowContextChoice

Editor.KeyBinder.BindToCommand(Keys.Control Or Keys.Space, "Editor.ContextChoice")

检查您的安装以获取此功能的工作示例。选择安装示例是个好主意,因为它们非常全面。

【讨论】:

  • 感谢您的回复以及如何使用绑定来做到这一点的示例。但它仍然在文本字段中输入空格字符。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-21
  • 2020-10-30
  • 2020-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多