我的问题是:
How can I disable the hold a key down in a textbox control using C#? e.g Boxxxxxxxxxxxxxxxxxxxxx
我不想让用户重复钥匙板的任何特性。
任何建议?
感谢
我的问题是:
How can I disable the hold a key down in a textbox control using C#? e.g Boxxxxxxxxxxxxxxxxxxxxx
我不想让用户重复钥匙板的任何特性。
任何建议?
感谢
仅对利用“关键发展”和“关键”活动镇压关键重复的每一个人附加说明。 如果你这样做,就必须排除诸如Alt/Shift等捕获杂货钥匙,否则这些钥匙不会被送去你想要的实际钥匙,因为这是两个关键的组合,而钥匙Down和“关键”事件会触及所有钥匙。
This applies to all two-key combinations. I did not add all of the meta keys to the following example, just the most common ones. You can easily add your own keys by adding them to the collection. Extending on the post from BFree:
public partial class Form1 : Form
{
private static readonly System.Collections.Generic.ICollection<System.Windows.Forms.Keys) ExcludeKeys = new System.Collections.Generic.HashSet<System.Windows.Forms.Keys)()
{
System.Windows.Forms.Keys.None,
System.Windows.Forms.Keys.Shift,
System.Windows.Forms.Keys.ShiftKey,
System.Windows.Forms.Keys.LShiftKey,
System.Windows.Forms.Keys.RShiftKey,
System.Windows.Forms.Keys.Alt,
System.Windows.Forms.Keys.Control,
System.Windows.Forms.Keys.ControlKey,
System.Windows.Forms.Keys.LControlKey,
System.Windows.Forms.Keys.RControlKey,
System.Windows.Forms.Keys.CapsLock,
System.Windows.Forms.Keys.NumLock,
System.Windows.Forms.Keys.LWin,
System.Windows.Forms.Keys.RWin
}
private bool isKeyPressed = false;
public Form1()
{
InitializeComponent();
this.textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown);
this.textBox1.KeyUp += new KeyEventHandler(textBox1_KeyUp);
}
void textBox1_KeyUp(object sender, KeyEventArgs e)
{
if (!ExcludeKeys.Contains(e.KeyCode))
{
isKeyPressed = false;
}
}
void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (!ExcludeKeys.Contains(e.KeyCode))
{
e.SuppressKeyPress = isKeyPressed;
isKeyPressed = true;
}
}
}
您可使用主要能源企业的SupressKeyPress财产:
public partial class Form1 : Form
{
private bool isKeyPressed = false;
public Form1()
{
InitializeComponent();
this.textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown);
this.textBox1.KeyUp += new KeyEventHandler(textBox1_KeyUp);
}
void textBox1_KeyUp(object sender, KeyEventArgs e)
{
isKeyPressed = false;
}
void textBox1_KeyDown(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = isKeyPressed;
isKeyPressed = true;
}
}
bool prevent = false;
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = prevent;
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
prevent = false;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
prevent = true;
}
我不熟悉C#中的具体内容,但我想到的是:
while (keyIsDown){
//do nothing
}
工作。 如果无法追踪一个关键因素,我将感到惊讶。
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...