<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Trapping Enter key in Windows Forms TextBox</title>
	<atom:link href="http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/</link>
	<description>Jouni Heikniemi&#039;s IT adventures</description>
	<lastBuildDate>Sat, 06 Mar 2010 13:46:36 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Róbert Badí Baldursson</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-12276</link>
		<dc:creator>Róbert Badí Baldursson</dc:creator>
		<pubDate>Thu, 10 Dec 2009 13:24:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-12276</guid>
		<description>Hi

This didn&#039;t work as expected for me originally untill I changed the event from KeyDown to KeyPress and then the event handler looks like this:

private void _example_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
     if (e.KeyChar == Convert.ToChar(13))
     {
          e.Handled = true;
	  _btn_Click(this, e);
     }
}</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>This didn&#039;t work as expected for me originally untill I changed the event from KeyDown to KeyPress and then the event handler looks like this:</p>
<p>private void _example_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)<br />
{<br />
     if (e.KeyChar == Convert.ToChar(13))<br />
     {<br />
          e.Handled = true;<br />
	  _btn_Click(this, e);<br />
     }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ALexanderT</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-7162</link>
		<dc:creator>ALexanderT</dc:creator>
		<pubDate>Fri, 02 Oct 2009 08:18:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-7162</guid>
		<description>just put this in an keydown or up event:

if (e.KeyData == Keys.Enter)
{
    //do action
}

easy, clean and quick</description>
		<content:encoded><![CDATA[<p>just put this in an keydown or up event:</p>
<p>if (e.KeyData == Keys.Enter)<br />
{<br />
    //do action<br />
}</p>
<p>easy, clean and quick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dameure</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-17</link>
		<dc:creator>Dameure</dc:creator>
		<pubDate>Thu, 10 Apr 2008 19:22:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-17</guid>
		<description>Thanks a lot. Great solution :-)
</description>
		<content:encoded><![CDATA[<p>Thanks a lot. Great solution :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allan K</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-16</link>
		<dc:creator>Allan K</dc:creator>
		<pubDate>Wed, 28 Mar 2007 06:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-16</guid>
		<description>Nice, just that I needed.
Alllan
/Denmark
</description>
		<content:encoded><![CDATA[<p>Nice, just that I needed.<br />
Alllan<br />
/Denmark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yuri</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-15</link>
		<dc:creator>Yuri</dc:creator>
		<pubDate>Mon, 26 Mar 2007 06:57:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-15</guid>
		<description>e.Handled = True. Too right.
Thanks a lot! IsInputKey&#039;s been driving me nuts.
</description>
		<content:encoded><![CDATA[<p>e.Handled = True. Too right.<br />
Thanks a lot! IsInputKey&#039;s been driving me nuts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xtian</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-14</link>
		<dc:creator>xtian</dc:creator>
		<pubDate>Mon, 18 Dec 2006 14:19:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-14</guid>
		<description>Oops - changed the form so that the AcceptButton was set, and saw exactly the behaviour you describe. Thanks!
</description>
		<content:encoded><![CDATA[<p>Oops &#8211; changed the form so that the AcceptButton was set, and saw exactly the behaviour you describe. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xtian</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-13</link>
		<dc:creator>xtian</dc:creator>
		<pubDate>Mon, 18 Dec 2006 14:06:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-13</guid>
		<description>Hmm - just tried this in .NET 2.0, and it seems that KeyPress is fired when an Enter is sent to a vanilla textbox. Is this something that&#039;s likely to have been fixed in the new version?
</description>
		<content:encoded><![CDATA[<p>Hmm &#8211; just tried this in .NET 2.0, and it seems that KeyPress is fired when an Enter is sent to a vanilla textbox. Is this something that&#039;s likely to have been fixed in the new version?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brief thanks</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-12</link>
		<dc:creator>brief thanks</dc:creator>
		<pubDate>Mon, 21 Aug 2006 10:12:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-12</guid>
		<description>you sir are a legend. congratulations upon receiving such an accolade.
saved me a good spot of google trawling (tm)
cheers buddy
;)
</description>
		<content:encoded><![CDATA[<p>you sir are a legend. congratulations upon receiving such an accolade.<br />
saved me a good spot of google trawling &#8482;<br />
cheers buddy<br />
;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-11</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Fri, 26 May 2006 20:40:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-11</guid>
		<description>Thank you.  This was very helpful.
I did note one thing that may help others.
I originally encountered this problem on a form with the AcceptButton property set to an &quot;OK&quot; button.
When I reset the AcceptButton property to &quot;(none)&quot;, I was able to intercept the ENTER button without overriding the IsInputKey method.
For me this, was an easier change.  I simply communicate the DialogResult differently.
-Eric.
</description>
		<content:encoded><![CDATA[<p>Thank you.  This was very helpful.<br />
I did note one thing that may help others.<br />
I originally encountered this problem on a form with the AcceptButton property set to an &#034;OK&#034; button.<br />
When I reset the AcceptButton property to &#034;(none)&#034;, I was able to intercept the ENTER button without overriding the IsInputKey method.<br />
For me this, was an easier change.  I simply communicate the DialogResult differently.<br />
-Eric.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pieter</title>
		<link>http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/comment-page-1/#comment-10</link>
		<dc:creator>Pieter</dc:creator>
		<pubDate>Tue, 14 Mar 2006 12:50:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikniemi.net/hardcoded/2004/08/trapping-enter-key-in-windows-forms-textbox/#comment-10</guid>
		<description>I like your solution Brian.
Saved me a lot of work with this trick.
Thx :)
</description>
		<content:encoded><![CDATA[<p>I like your solution Brian.<br />
Saved me a lot of work with this trick.<br />
Thx :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
