This is my very first thread on the net period, I'll do my best to describe my c# problem. I was wondering if there is any way of calling upon general event trigger objects (referring to buttons, picture box etc.) on a whole, for example is there a keyword that i can use to do this.
I want multiple picture boxes to be handled by one event and I want to be able to make each picture box invisible when I move the mouse over it, without having to name the picture boxes individually. Is this possible?
pickleleon
0
Newbie Poster
Recommended Answers
Jump to Post>I want multiple picture boxes to be handled by one event ..
You want to write single event handler for multiple picture boxes.
private void Form1_Load(object sender, EventArgs e) { picture1.MouseEnter += new EventHandler(MyHandler); picture2.MouseEnter+=new EventHandler(MyHandler); } void MyHandler(object sender, EventArgs e) { PictureBox currentPic = …
Jump to PostFor events the
sender
object is the object triggering the event.
Try this.private void picturebox1_MouseMove(object sender, MouseEventArgs e) { PictureBox pb = sender as PictureBox; if(pb !=null) { pb.visibility = false; } }
All 5 Replies
kvprajapati
1,826
Posting Genius
Team Colleague
nick.crane
342
Veteran Poster
pickleleon
0
Newbie Poster
nick.crane
342
Veteran Poster
pickleleon
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.