int count;
int i = 0;
int x = 5;
int y=10;
Panel[] pnl_new_ = new Panel[10];
PictureBox[] usr_pic_ = new PictureBox[10];
Label[] lbl_username_ = new Label[10];
Label[] lbl_account_type_ = new Label[10];
private void button1_Click(object sender, EventArgs e)
{
i = Convert.ToInt32(txt_num.Text);
for (count = 0; count < i; )
{
Panel pnl = new Panel();
pnl.Location = new Point(x, y);
pnl.Size = new Size(238, 97);
pnl.BackColor = Color.LightGray;
pnl.Cursor = System.Windows.Forms.Cursors.Hand;
//pnl.MouseLeave += new EventHandler(pnl_MouseLeave);
//pnl.MouseHover += new System.EventHandler(pnl_MouseHover);
pnl_new_[count] = pnl;
pnl_new_[count].MouseHover+=new EventHandler(Manage_Another_Account_frm_MouseHover);
grp_account.Controls.Add(pnl_new_[count]);
PictureBox pic = new PictureBox();
pic.Location = new Point(12, 12);
pic.Size = new Size(70, 74);
pic.BackColor = Color.Green;
usr_pic_[count] = pic;
pnl_new_[count].Controls.Add(usr_pic_[count]);
Label lbl_name = new Label();
lbl_name.Location = new Point(94, 21);
lbl_name.Size = new Size(122, 18);
lbl_name.Text = "Sunita Shrestha";
lbl_name.ForeColor = Color.Green;
lbl_name.Font = new Font("Tahoma", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
lbl_username_[count] = lbl_name;
pnl_new_[count].Controls.Add(lbl_username_[count]);
Label lbl_actype = new Label();
lbl_actype.Location = new Point(94, 47);
lbl_actype.Size = new Size(122, 18);
lbl_actype.Text = "Administrator";
lbl_actype.ForeColor = Color.Black;
lbl_actype.Font = new Font("Tohama", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
lbl_account_type_[count] = lbl_actype;
pnl_new_[count].Controls.Add(lbl_account_type_[count]);
count = count + 1;
x += 257;
}
}
public void Manage_Another_Account_frm_MouseHover(object sender, EventArgs e)
{
pnl_new_[count].BackColor = Color.Green;
}
public void pnl_MouseHover(object sender, EventArgs e)
{
pnl[1].BackColor=Color.Green;
}
//This did not work any idea...
//The system couldnot define which control was selected... there was the error in count too.. caus i have defined count already above as a globle value...