softairhk

softairhk

  • NA
  • 115
  • 0

How to enable the txtName has the Click function?

Nov 7 2003 2:17 AM
Hello! I would like to make the txtName.Text inputted and press enter got the private void btnShowName_Click function? What's wrong for my coding at private void txtName_KeyPress? Please give me reply asap. Thanks! private void btnShowName_Click(object sender, System.EventArgs e) { string sName=txtName.Text; if(sName.Length!=0) { string sYourName = "Your name is " + sName; MessageBox.Show(sYourName,"Show Name"); } else { MessageBox.Show("Name space should not be empty!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } } private void txtName_KeyPress(object sender, System.EventArgs e) { string sName=txtName.Text; if(sName.Length!=0) { string sYourName = "Your name is " + sName; MessageBox.Show(sYourName,"Show Name"); } else { MessageBox.Show("Name space should not be empty!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } }