111,098
社区成员




-
- private void Form1_Load(object sender, EventArgs e)
- {
- this.pictureBox1.PreviewKeyDown += PictureBox1_PreviewKeyDown;
- }
- private void PictureBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
- {
- if (e.Modifiers == Keys.Control && e.KeyCode == Keys.C)
- {
- MessageBox.Show("复制");
- }
- }
private void pictureBox1_PreviewKeyDown_1(object sender, PreviewKeyDownEventArgs e)
{
if (e.Modifiers == Keys.Control)
{
if (e.KeyCode == Keys.C)
MessageBox.Show("复制");
}
}
private void test_Activated(object sender, EventArgs e)
{
pictureBox1.Focus();
}
Panel 之类的 要设置Focusable 或者Clickable之类的属性为Ture,好让控件接受焦点
先设置焦点private void Form1_Activated(object sender, EventArgs e) { pictureBox1.Focus(); } private void pictureBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { MessageBox.Show("111"); }
事件不触发,打断点也不进入调试模式!请问各位大佬,这是为什么?private void Form1_Load(object sender, EventArgs e) { this.pictureBox1.PreviewKeyDown += PictureBox1_PreviewKeyDown; } private void PictureBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.Modifiers == Keys.Control && e.KeyCode == Keys.C) { MessageBox.Show("复制"); } }
Load事件没有Handle怎么会出发Load事件呢?
private void Form1_Activated(object sender, EventArgs e)
{
pictureBox1.Focus();
}
private void pictureBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
MessageBox.Show("111");
}
你这是不允许复制图片?这个要用钩子拦截键盘吧
KeyPreview要设为true