将鼠标单击事件处理程序添加到图片框 [英] Adding a mouse click eventhandler to a PictureBox
本文介绍了将鼠标单击事件处理程序添加到图片框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图片框控件,单击它后,另一个图片框会出现在特定位置.I.o.w 它不是从工具箱中添加的.
I have a picturebox control and upon clicking it another PictureBox appears at a specific location. I.o.w it wasnt added from the toolbox.
PictureBox picOneFaceUpA = new PictureBox();
picOneFaceUpA.Location = new Point(42, 202);
picOneFaceUpA.Width = 90;
picOneFaceUpA.Height = 120;
picOneFaceUpA.Image = Image.FromFile("../../Resources/" + picFaceUpToBeMoved[0] + ".png");
Controls.Add(picOneFaceUpA);
picOneFaceUpA.BringToFront();
如何向该控件添加 MouseClick 事件处理程序?
How would I add a MouseClick eventhandler to this control?
谢谢
推荐答案
只需使用 +=
运算符添加事件处理程序:
Just add an event handler using the +=
operator:
picOneFaceUpA.MouseClick += new MouseEventHandler(your_event_handler);
或者:
picOneFaceUpA.MouseClick += new MouseEventHandler((o, a) => code here);
这篇关于将鼠标单击事件处理程序添加到图片框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文