Click here to Skip to main content
13,249,401 members (31,371 online)
Rate this:
Please Sign up or sign in to vote.
See more:
In a class, I have an array of panels which each contains the same picturebox.

public Panel[] NumberPanel;
public PictureBox AddBox;
AddBox.Click += new System.EventHandler(AddBox_Click);

When creating an object it creates the panel and the picture in it.

How can I know the index of the panel when clicked on one of the pictures in one of the panels.

private void AddBox_Click(object sender, EventArgs e)
int index;
Posted 23-Dec-12 7:51am
Updated 23-Dec-12 8:26am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I dont think that there is any direct method since its you defines the class structure you need to keep the index of the panel as a member to the insider control.

I believe you have used a custom control to create your object which holds panel and picturebox.

One thing you can do is expose custom event which simulates that picbox inside the panel(customcontrol) is clicked by keeping the index as a property to the custom control or class which holds the panel/picture box.
missak boyajian 23-Dec-12 14:46pm
When i create the object q1[0]= new drawing(X,y); it draws the panel at specific x y position. But when the user clicks on the picture i need to know which one is clicked like q1[?]. Picture. I didnt understand your explanation.
jibesh 23-Dec-12 14:51pm
how the panel and picture are related? are they clubbed to one control?

The idea is like you know the index when you are creating the panel/image i mean q1[0] here '0' means the index. store this information also into the drawing class.

can you add more details about your code to understand more and to have a better solution for this. You can use the 'Improve Question' button to update your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100