definition
January 30th, 2006, 04:35 AM
Hey can any of you guys tell me how to get an event handler to fire off a text box when i hit enter or return. I checked the microsoft documentation, however its method doesnt actually fire an event when the keys are pressed to check if it is the enter or return keys.
editBox.AcceptsReturn = true;
editBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.EditOver);
private void EditOver(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
//ascii decimal values
if (e.KeyChar == (char)13)
{
lstABList.Items[itemSelected] = editBox.Text;
editBox.Hide();
this.btnABSelect.Enabled = true;
updateHandsetContacts();
}
if (e.KeyChar == (char)27)
{
Console.Out.Write("");
loadContactsFromModel();
}
}
It does however fire when i press other keys, like letters or numbers. Can anyone help?
editBox.AcceptsReturn = true;
editBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.EditOver);
private void EditOver(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
//ascii decimal values
if (e.KeyChar == (char)13)
{
lstABList.Items[itemSelected] = editBox.Text;
editBox.Hide();
this.btnABSelect.Enabled = true;
updateHandsetContacts();
}
if (e.KeyChar == (char)27)
{
Console.Out.Write("");
loadContactsFromModel();
}
}
It does however fire when i press other keys, like letters or numbers. Can anyone help?