Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.