一个示例: private void txtPosNameLoc_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13 &&txtPosNameLoc.Text.Length > 0) btnLocation_Click(sender, null); }