using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Project.Dialog { public partial class fPassword : Form { public fPassword() { InitializeComponent(); this.tbInput.KeyDown += (s1, e1) => { if (e1.KeyCode == Keys.Enter) btLogin.PerformClick(); }; this.KeyPreview = true; this.KeyDown += (s1, e1) => { if (e1.KeyCode == Keys.Escape) this.Close(); }; } private void button1_Click(object sender, EventArgs e) { string id = tbInput.Text.Trim(); if (id.isEmpty()) { tbInput.Focus(); return; } DialogResult = DialogResult.OK; } } }