CODE
public partial class Form1 : Form
{
//......(other code)
private void createPanels()
{
for (int i = 0; i < caseNum; i++)
{
this.casePanels[i] = new PanelControl(cases[i].manufacturer, cases[i].name, cases[i].price, cases[i].imageName);
this.tabPage1.Controls.Add(this.casePanels[i]);
this.casePanels[i].Click += new System.EventHandler(this.panelControl_Click);
this.casePanels[i].Name = "panelControlA";
this.casePanels[i].Parent = panel1;
this.casePanels[i].BringToFront();
Point p = new Point();
p.X = panel1.Location.X;
p.Y = panel1.Location.Y + (100 * i);
this.casePanels[i].Location = p;
}
}
private void panelControl_Click(object sender, EventArgs e)
{
PanelControl pc = (PanelControl)sender;
pc.Location = new Point(500, 500);
}
}
The Relevant code from my Form.
This is the event I want to fire. The panelControl is my User Control that contains a panel, 3 labels, and a pic box. They fire their individual events, but I want the overall control to fire its own event. If I put a regular button on the form it will fire its own events. I want to put my user control on and have it fire its own events.
CODE
public partial class PanelControl : UserControl
{
private String imageDir;
private bool isSelected;
public PanelControl()
{
InitializeComponent();
}
public PanelControl(string mnf, string nm, double prc, string img)
{
InitializeComponent();
imageDir = Directory.GetCurrentDirectory() + "\\" + "Images" + "\\";
label1.Text = mnf;
label2.Text = nm;
label3.Text = prc.ToString();
imageBox.ImageLocation = imageDir + "img";
}
private void panelControl_MouseLeave(object sender, EventArgs e)
{
a1Panel1.GradientEndColor= Color.DodgerBlue;
}
private void panelControl_MouseEnter(object sender, EventArgs e)
{
a1Panel1.GradientEndColor = Color.Black;
}
This is the code for my User Control. All the child controls that make up my User control fire these events.