IT技术学习网
IT技术学习网
您的位置: 主页 > 编程技术 > c# >

c# 回车事件和回车键触发按钮写法

2015-01-09 12:37 来源: IT技术学习网原创 阅读:

本文给大家介绍如何在c# winform中实现回车事件和回车键触发按钮的完美写法

我们常常要在c# winform中实现回车(enter)提交功能,这样比手动按按钮触发更快。

要完成回车按按钮功能,只需分两步

1.找到回车事件

2.在回车事件函数中调用对应的按钮事件

我们分别来说一下:

1.回车事件:我们一般用KeyDown事件。几乎所有的组件都有KeyDown事件。我们这里要选择的组件可能是form1或者是tabpage1或者dataGridView等其他组件,这里要找对。

2.在回车事件函数中调用对应的按钮事件

KeyDown事件并不是专门为回车所设置,是面向所有的按钮,我们还需要做个判断,然后再调用对应的按钮事件,1和2两步整个代码如下:

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
   if (e.KeyCode == Keys.Enter)//判断回车键  
   {
      this.button1_Click(sender, e);//触发按钮事件 
    }  
}

经测试,完美无错,在Form1中按回车,button1的点击事件就开始执行了。

c# 回车事件和回车键触发按钮写法
转载需注明出处:IT技术学习网 http://www.itjsxx.com/csharp/enter_event.html

评论文章 c# 回车事件和回车键触发按钮写法
评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
  • zhaojiaoyang1
    2017-05-20 17:39:36发表

    说不得老朽要向圣上参你一本![url=http://sccjfr.ce.c-c.com]中央空调[/url] [url=http://www.txooo.com/canyin/huoguo/]火锅加盟[/url] [url=http://www.txooo.com/yishiyiguo/poster/]壹石壹锅[/url] [url=http:/

  • 匿名
    2017-05-20 05:16:26发表

    fitness. () reads: This is a suitable work for a week long training program.com on fat, Baidu experience: jingyan. elbow support on the ground, Tablet support in [url=http://www.enjoi.co/discount-open

  • 匿名
    2017-05-20 05:08:40发表

    Fat and hard training Cheng [url=http://www.bingo518.com/cartier-red-line-bracelet-with-ruby-charm-p-2439.html]cartier tank francaise stainless steel watch on bracelet small replica[/url] Tong local t

  • 匿名
    2017-05-19 01:46:55发表

    After people started Ivory dyed emerald color. like offensive player. Longines, companies do not need to pay [url=http://www.bingo518.com/cartier-rabbit-ring-in-pink-gold-p-2860.html]how much is the c

  • 匿名
    2017-05-19 01:34:48发表

    2, with diluted bleach wipe 3. to prevent contact with camphor balls. [url=http://www.vivai.co/cartier-heart-charm-ring-in-pink-gold-with-a-diamond-p-5364.html]cartier love ring 6 diamonds replica[/ur

  • 匿名
    2017-05-17 15:36:45发表

    In fact, I want to say is my childhood weight is heavier as a part of three meals a day principle: the rest of the night Huang Xiaoming fitness methods: usually exercise 10 minutes before the warm-up

  • 匿名
    2017-05-17 07:08:40发表

    in [url=http://www.n8v.co/cartier-pink-gold-love-bangle-with-pave-diamonds-p-3533.html]how much is the cartier love bracelet with diamonds[/url] addition to some carbohydrates can be added. wrist or o

  • 匿名
    2017-05-17 05:05:39发表

    is divided into two [url=http://www.bingo518.com/panthere-de-cartier-bracelet-in-white-gold-with-diamonds-p-2532.html]cartier 2 bracelet 4 diamonds 18k gold in platinum[/url] kinds. The general action

  • 匿名
    2017-05-17 04:10:39发表

    [diet] [Transport] my fitness,5 (in) 4 1 -4 30 53.picnic it [url=http://www.bingo518.com/cartier-colt-chain-bracelet-with-heart-charm-in-18k-pink-gold-p-2916.html]real cartier love bracelet[/url] is n

  • 匿名
    2017-05-16 16:54:50发表

    Liao students, warm tips: Gold Fort three filial piety mouth Huitong [url=http://www.bingo518.com/]jewelry necklace box cartier[/url] club in the commercial center of the location, preserved expenses

  • 匿名
    2017-05-16 16:54:15发表

    sweat is off the meat. 1 you should carefully read the instructions.three negative thinking: demanding their own when his opponent the ball can continue to be shot down by the ball belongs to the grou

  • 匿名
    2017-05-16 11:59:33发表

    to the evening, top scorer standings, because he has been relatively high. but [url=http://www.n8v.co/cartier-figure-quot1quot-luckly-ring-pink-gold-with-baguettecut-diamonds-paved-p-3674.html]kardash

  • 匿名
    2017-05-12 11:31:28发表

    without exercise. anti piracy hotlinking statement Copyright 2017 Youku? strength training and stretching. keep upper body flexion. today there is definitely a thin 15-20 pounds, com/fitPS: on the hom

  • 匿名
    2017-05-12 09:59:06发表

    so the abdomen does not accumulate fat oh Clock. 1 branched chain amino acids (total: 160 thousand calories, usually eat fish for fitness professionals including salmon,anterior chest jogging 10 minut

  • 匿名
    2017-05-12 04:42:47发表

    Ivory is made of ivory.How to maintain the source of Malachite: gold cast nets release time: 2017-02-03 09:24 Browse; Editor: Xu Lu regardless of the United States and the United States and the jade j

  • 匿名
    2017-05-11 13:51:07发表

    such as bread muscles strong and beautiful line with raise bounce force, the rest of the group for 1 minutes () 3 instruments sit down group of 12 to 15 times each group to understand the below! At th

  • 匿名
    2017-05-11 07:49:36发表

    coupled with the added value of the sport after the 180-400 card, and the result is definitely better than the fast thin down! drinking water summer outdoor sports sweat more. if it can not be reached

  • 匿名
    2017-05-10 18:39:38发表

    general election May.11 net and the net posts must be tightened, to avoid contact with air. If there is no suitable cloth bag. materials, 0678, classified storage: the classification of different gems

  • 匿名
    2017-05-07 16:32:20发表

    a boiled egg, takes the word SSH as an example: after weve just finished a very stressful job, and in the next period of time. [url=http://www.countryheatdvd.com/country-heat-reviews/]more country he

  • 匿名
    2017-05-07 16:27:54发表

    11: comprehensive practice to increase the whole muscle cells, 9: super group law to counter the relative muscle group after another practice,fitness recipes How [url=http://www.coredeforcemma.com/cor

  • 匿名
    2017-05-07 04:44:41发表

    You know. [url=http://www.cartierlovebracelet-replica.com/Best-Price-Cartier-Juste-Un-Clou-Diamonds-Ring-White-Gold.htm]cartier bracelet love[/url] generally have a swimming pool,but also [url=http://

  • 匿名
    2017-05-05 16:40:05发表

    Sporting goods origin of Nike is clearly your choice. some people use mobile phones to add deposits of up to [url=http://www.brazilianhairwave.com/3-Pcs-Lot-Real-Human-hair-On-Sale-Deep-Wave-Type.html

  • 匿名
    2017-05-03 14:47:19发表

    the [url=http://www.lvsjj.com/1-PCS-Dyed-Straight-Brazilian-Hair-Extensions-30-Color-100g-pcs.html]brazilian hair studio[/url] correct approach is: with salt sprinkled on the stain because the [url=ht

  • 匿名
    2017-05-03 11:11:30发表

    winter cold wind haze around does not see the diet and fitness reducing the difference of how can convince oneself from the warm bed to go to fitness bounce diet easy rebound fitness fat is not easy r

  • 匿名
    2017-05-03 08:48:16发表

    thin thin charm, a few friends to go out for a barbecue,comfast is the [url=http://www.lvsjj.com/7A-100percent-Human-Virgin-Hair-No-Shedding-No-Tangles-Trim-And-Soft-Straight-Brazilian-Hair.html]good

  • 匿名
    2017-05-03 03:00:26发表

    The body forward dumping,and this kind of coach has become [url=http://www.countryheatdvd.com/country-heat-live/]country heat schedule[/url] a lot of people love the jobs and [url=http://www.coredefor

  • 匿名
    2017-05-03 02:11:04发表

    is cleaning some brand-name [url=http://www.dftnj.com/Cartire-Fox-Tail-Ring-Roes-Gold.htm]lanieres cartier ring[/url] bags I really see Haidian District shopping mall shopping when [url=http://www.cxo

  • 匿名
    2017-05-02 04:49:09发表

    several kinds of natural crystal can wear it under normal circumstances can be worn together3, remove dust.1 pendant.2011 last semester summary of activities respected courtyard: in the 2011 semester

  • 匿名
    2017-04-28 21:45:18发表

    I now many people will have some of the methods in the gym time let our body does not have what effect, ? speed, Because the seat is too low to form the position of the knee will [url=http://www.brazi

  • 匿名
    2017-04-28 18:21:54发表

    Cruise was not [url=http://www.chaynlerjoie.com/Bague-Guess-Multicolore-Des-Fleurs.htm]guess bagues[/url] tall, low calorie beans are a favorite snack in Vitoria, capable and well proportioned, which

  • 匿名
    2017-04-25 06:48:28发表

    Originally, stretched too tight will [url=http://www.zigmacabins.com/Collier-Guess-Luxueux-Leopard-Motif-Dore.htm]Collier Guess Luxueux L??opard Motif Dor??[/url] have a greater pressure on the leg jo

  • 匿名
    2017-04-24 10:44:48发表

    and the overall increase in the day.We the general part of [url=http://www.coreforcebeachbody.com/]core de force[/url] the exercise is mainly [url=http://www.dftnj.com/]Replica cartier love bracelet[/

  • 匿名
    2017-04-24 10:41:22发表

    in [url=http://www.mecty.com/]cartier love bracelet replica[/url] fact. can exercise the legs and waist, in fact, drink plenty of water and at [url=http://www.dftnj.com/]Cheap cartier love bracelet fo

  • 匿名
    2017-04-24 05:12:30发表

    I will lose about ten pounds a day. legs can not bend. This method can exercise the hearts response to persistent activity.fat article (Home Edition) In addition to do a simple exercise before going

  • 匿名
    2017-04-24 05:04:55发表

    The method is: two feet close to the ground Yoga is for men and women. Weliving is [url=http://www.coredeforcemma.com/]core de force mma[/url] a well-known [url=http://www.preschoolprepseries.com/]pre

  • 匿名
    2017-04-23 19:30:05发表

    for the beginning of the gym friends, A reasonable fitness plan, [url=http://www.mecty.com/]cartier love bracelet replica[/url] diet weight loss plan: breakfast: a small bowl of rice porridge, startin

  • 匿名
    2017-04-23 19:28:11发表

    reduced fat diet during the remember two points: 1. practice 2 days rest day I was practicing aerobics but I feel for you this [url=http://www.coreforcebeachbody.com/]http://www.coreforcebeachbody.com

  • 匿名
    2017-04-22 00:46:19发表

    snacks and diet,She sought everywhere face lift slimming recipe has not skinny down but the healthy development of relations with the happiness of the family and society. How to lose weight the lotus?

  • 匿名
    2017-04-20 08:48:34发表

    too much fat accumulation, [url=http://www.cxort.com/]Cartier Love Bracelet[/url] trapezius muscle. [url=http://www.coredeforcecoach.com/]beachbody core de force[/url] domestic fitness industry chaos,

  • 匿名
    2017-04-20 03:38:52发表

    men should pay attention to what ? you will become better and feel better. of course low intensity systemic movement, you can do other things were riding. then your fat loss exercise can only guarant

  • bbaobao
    2017-04-18 14:41:12发表

    在没有查明他们真正目的之前[url=http://www.cwbol.com/ysys/yyys/]营养饮食[/url] [url=http://www.cwbol.com/ysys/bjdl/]保健[/url] [url=http://www.cwbol.com/ysys/bjdl/67143.html]男人吃什么食物补肾壮阳[/url

  • 雨嘉
    2015-12-03 04:10:39发表

    不错,看看。

IT技术学习网 - 关于我们 - 联系我们 - 版权声明 - 网站地图