按Enter键时如何避免选择文本框值?

时间:2015-06-20 05:02:56

标签: c# windows enter

Control nextControl;
if (e.KeyCode == Keys.Enter)
{     
    nextControl = GetNextControl(ActiveControl, !e.Shift);
    if (nextControl == null)
    {
        nextControl = GetNextControl(null, true);
    }
    nextControl.Focus();               
    e.SuppressKeyPress = true;
 }

我有这个代码将ENTER键作为TAB,但是当我按下Enter键时,它选择文本框值,如图像

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以告诉TextBox不要选择任何内容

codename  minTimePrice  minTimeDis  minTime              latestPrice  latestPriceDis  latestPriceTime
1234      599           50          2015-06-10 00:00:00  1099         25              2015-06-11 00:00:00
3344      199           33          2015-06-12 00:00:00  199          33              2015-06-12 00:00:00
5565      1299          50          2015-06-14 00:00:00  1299         50              2015-06-14 00:00:00