键枚举有哪些格式可用?
我有下一个问题。我需要以文本形式表示按下的按键组合。我从 KeyEventArgs e 得到了按键... 当我尝试使用以下代码时 e.KeyData.ToString(); 我得到了这样的东西:N, Control ....但我想得到Ctrl+N字符串。
我认为这必须是 String.Format 的特定格式,因为当我将 Keys 类型的属性绑定到我在表格单元格中看到的 DataGridView 时字符串Ctrl+N。这意味着 DataGridView 可以做到这一点,而且我认为这不是手动完成的......
非常感谢!
I have a next problem. I need to represent a pressed keys combination in a text form. I got pressed keys from KeyEventArgs e...
And when I try to use following code
e.KeyData.ToString(); I got something like this: N, Control .... But I want to get Ctrl+N string.
I think that must be present specific format for String.Format because when i bind property with type Keys to the DataGridView I saw in the table cell string Ctrl+N. It's mean that DataGridView can do this, and i think this is not done manually...
Thanks a lot!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Keys 值可能使用其所属的 TypeConverter 显示。
如果您想模拟 DataGridView 的行为,您应该使用
Keys 类型标记为
[TypeConverter(typeof(KeysConverter))]
,这是GetConverter
应该返回的内容。The Keys values are probably displayed using the TypeConverter belonging it.
If you want to emulate the behavior of the DataGridView, you should use
The Keys type is tagged with
[TypeConverter(typeof(KeysConverter))]
, which is whatGetConverter
should return.根据MSDN,没有内置的东西可以做到这一点。我怀疑网格只是用“,”代替“+”。
According to MSDN, there is nothing built-in to do this. I suspect the grid is just substituing ", " for "+".