为什么有些文本框默认不接受

为什么有些文本框默认不接受

本文介绍了为什么有些文本框默认不接受 Control + A 快捷方式来全选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的程序中发现了一些文本框,它们接受 Control+A 快捷方式以默认"选择无编码"的整个文本.

I have found a few textboxes here and there in my program that accepts Control+A shortcut to select the entire text "by default" with "no coding".

我不知道我必须在这里提供哪些附加信息才能为所有这些文本框启用它,因为我发现这些文本框之间完全没有区别.它们都是简单的拖放文本框.

I don't know what additional information I have to give here to enable it for all of them, as I find absolutely no difference between these textboxes. They are all simple dragged and dropped textboxes.

注意:我不是在谈论这段代码:

Note: I'm not talking about this piece of code:

if (e.Control && e.KeyCode == Keys.A)
{
    textBox1.SelectAll();
}

我想要默认选择...或者无论如何要更改文本框属性,以便文本框接受所有默认窗口快捷方式?

I want selection by default... or is there anyway to change textbox property so that textboxes accept all default windows shortcuts?

其他一切(Control + ZControl + XControl + CControl + V)默认情况下工作!为什么不Control + A?

Everything else (Control + Z, Control + X, Control + C, Control + V) works by default! Why not Control + A?

更新:默认接受 Ctrl+A 的文本框是 屏蔽文本框,不是常规的.那时我正在使用 .NET 2.0.但是我猜原来的问题是别的,因为我可以看到 Ctrl+A 在 .NET 2.0 代码中默认工作正常.

Update: The text boxes that accepted Ctrl+A by default were masked textboxes, not the regular one. And at that point I was with .NET 2.0. But I guess the original problem was something else, as I can see Ctrl+A working fine by default in .NET 2.0 code.

推荐答案

您可能正在寻找 ShortcutsEnabled 属性.将其设置为 true 将允许您的文本框实现 + 快捷方式(等等).来自文档:

You might be looking for the ShortcutsEnabled property. Setting it to true would allow your text boxes to implement the + shortcut (among others). From the documentation:

使用 ShortcutsEnabled 属性来启用或禁用以下快捷键组合:

  • +

+

+

+

+

+

+

+

+

+

+

+

+

但是,文档 状态:

TextBox 控件没有当Multiline 属性值为 true.

您可能必须使用 TextBoxBase 的另一个子类,例如 RichTextBox,使其工作.

You will probably have to use another subclass of TextBoxBase, such as RichTextBox, for that to work.

这篇关于为什么有些文本框默认不接受 Control + A 快捷方式来全选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 05:52