<p>I have a user that want to be able to select a textbox and have the current text selected so that he doesn't have to highlight it all in order to change the contents.  </p>

<p>The contents need to be handle when enter is pushed.  That part I think I have figured out but any suggestions would be welcome. </p>

<p>The part I need help with is that once enter has been pushed, any entry into the textbox should clear the contents again.</p>

<p><strong>Edit:</strong> The textbox controls an piece of RF hardware.  What the user wants to be able to do is enter a setting and press enter.  The setting is sent to the hardware.  Without doing anything else the user wants to be able to type in a new setting and press enter again.</p>

[{'answer_id': 16119, 'author': 'Rob Cooper', 'author_id': 832, 'author_profile': 'https://Stackoverflow.com/users/832', 'pm_score': 1, 'selected': False, 'text': '<p>OK, are you sure that is wise? I am picturing two scenarios here:</p>\n\n<ol>\n<li>There is a default button on the form, which is "clicked" when enter is pushed".</li>\n<li>There is no default button, and you want the user to have to press enter, regardless.</li>\n</ol>\n\n<p>Both of these raise the same questions:</p>\n\n<ul>\n<li>Is there any validation that is taking place on the text?</li>\n<li>Why not create a user control to encapsulate this logic?</li>\n<li>If you know the enter button is being pushed and consumed fine, how are you having problems with <em>TextBoxName.Text = string.Empty</em> ?</li>\n</ul>\n\n<p>Also, as a polite note, can you please try and break up your question a bit? One big block is a bit of a pain to read..</p>\n'}, {'answer_id': 16130, 'author': 'Greg Hurlman', 'author_id': 35, 'author_profile': 'https://Stackoverflow.com/users/35', 'pm_score': 3, 'selected': True, 'text': '<p>Hook into the KeyPress event on the TextBox, and when it encounters the Enter key, run your hardware setting code, and then highlight the full text of the textbox again (see below) - Windows will take care of clearing the text with the next keystroke for you.</p>\n\n<pre><code>TextBox1.Select(0, TextBox1.Text.Length);\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/16110', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1629/']