111,129
社区成员
发帖
与我相关
我的任务
分享
public Form1()
{
InitializeComponent();
this.KeyPreview = true;//必须加这句,否则KeyDown事件不执行
}
private void button1_Click(object sender, EventArgs e)
{
this.Text = "新标题";//设置窗口的标题
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F2)//用户按下F2键
{
//执行button1的click事件处理程序
this.button1_Click(this.button1, EventArgs.Empty);
}
}