如何将事件处理程序分配给Windows forms consplice C#中的编程创建的PictureBox
?编辑:
我尝试过,它给出了错误
无超载picturebox_mousedown
this.ListFrameImage[i].MouseDown += new EventHandler(this.pictureBox_MouseDown);
private void pictureBox_MouseDown(object sender, MouseEventArgs e)
{
someX = e.X;
someY = e.Y;
drag = true;
}
只需使用 = operator添加事件处理程序:
pictureBox.MouseClick += new MouseEventHandler(your_event_handler);
或:
pictureBox.MouseClick += new MouseEventHandler((o, a) => code here);
写入 =将生成处理程序后敲击选项卡。或者你可以写手动:
pictureBox.MouseClick += pictureBox_MouseClick;
void pictureBox_MouseClick(object sender, MouseEventArgs e)
{
// blah
}