title: Read text from textbox in Coded UI Tests
body: <p>There is a bug/limitation in the Coded UI Test <code>WinEdit</code> class: when overriding the <code>OnKeyDown</code> method or subscribing to the <code>KeyDown</code> event in a text box, it is not possible to use the <code>WinEdit.Text</code> property.</p>
  
  <p>That is, when you have this...</p>
  
  <pre><code>private void myTextbox_KeyDown(object sender, KeyEventArgs e)
  {
      // ...
  }
  </code></pre>
  
  <p>...this won't work:</p>
  
  <pre><code>var edit = new WinEdit(ancestor);
  edit.SearchProperties[WinControl.PropertyNames.ControlName] = "myTextbox";
  edit.Text = "New value"; // This doesn't work
  </code></pre>
  
  <p>I've found a work-around for setting the value <a href="http://social.msdn.microsoft.com/Forums/pl-PL/vsautotest/thread/224da6d4-47f3-44e6-a383-63b3e32bbfb4" rel="nofollow">here</a>:</p>
  
  <pre><code>var edit = new WinEdit(ancestor);
  edit.SearchProperties[WinControl.PropertyNames.ControlName] = "myTextbox";
  Mouse.Click(edit);
  System.Windows.Forms.SendKeys.SendWait("New value");
  </code></pre>
  
  <p><strong>My question:</strong> does anyone know a work-around for reading the value?</p>
  
  <pre><code>var edit = new WinEdit(Window);
  edit.SearchProperties[WinControl.PropertyNames.ControlName] = "myTextbox";
  string actual = edit.Text; // This doesn't work
  </code></pre>