Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

KeyPress Event doesn't copy last character from text box.

ReubenCReubenC Posts: 2Member
Situation:
A form has a text box in which the user must type some text. This text box has a KeyPress event in which the Form's text property changes to the text that the user types with each keystroke.

Here's the code for the textbox's KeyPress Event:

private void tbGameTitle_KeyPress(object sender, KeyPressEventArgs e)
{
this.Text = textBox1.Text;
}

Problem:
The last character the user types doesn't get copied to the Form's text. Example:

textBox1.Text = "The War of 1812"
Form2.Text = "The War of 181"

The "2" at the end of textBox1.Text doesn't get copied! How can I get the whole text string to copy to the form's text?
Sign In or Register to comment.