一个示例:
private void txtPosNameLoc_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13 &&txtPosNameLoc.Text.Length > 0)
btnLocation_Click(sender, null);
}
在响应enter事件时检测是否textbox。text。trim()为空,
keycode事件。判断keycode 是否为Enter