AcceptsReturn的文本框无法正常工作 [英] AcceptsReturn on TextBox not functioning correctly
问题描述
我有被设置为多行(我的理解是要改变文本框的高度的唯一方法)在窗体上一个简单的搜索框,并具有标志AcceptsReturn设置为false。
I have a simple search field on a form that is set as multiline (which I understand is the only way to change a text box's height) and has the flag AcceptsReturn set to false.
然而,当我$的控制范围之内p $ PSS进入,而不是它激活默认按钮,因为它应该,它把在符。
However, when I press enter within that control, instead of it activating the default button as it should, it puts in a return character.
现在,我也尝试使用密钥preSS事件来检查,如果回车键一直pssed激活,希望它会重写此返回行为的搜索按钮,点击功能$ P $ - 但它没有。现在,它只是运行搜索并插入符。
Now, I've also attempted using the KeyPress event to check if the Enter key has been pressed to activate the search-button click function in the hope that it would override this return behaviour - but it hasn't. Now it just runs the search AND inserts a return character.
我运行Visual Studio 2010(尽管这个问题似乎是present在2008年过之前,我将它转换)和C#.NET 2.0。任何解决办法?
I'm running Visual Studio 2010 (although this problem seemed to be present in 2008 too before I converted it) and C# .NET 2.0. Any solutions?
推荐答案
窗体有一个名为属性的 AcceptButton 的。是指向按钮,您呼叫的的默认按钮的?
The form has a property called AcceptButton. Is that pointing to the button you are calling the default button?
我刚写了一个小测试,它似乎为我工作。
I just wrote a little test and it seems to work for me.
这篇关于AcceptsReturn的文本框无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!