• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

making event to panel that added in running time

hi,
 in my program i add Panels in this way
              Panel p = new Panel();
               // set properties
               p.Top = 0;
               p.Left =0;
               p.Height =100;
               p.Width = 100;
               p.BackColor = Color.Red ;
               //add the panel
               this.Controls.Add(p);
in my MouseMove Event of these Panels, How can i check the properties of the panel i am making an event on it.

the compiler write to me that the namespace couldn't be found, because i am adding panels in running time and not in design time


thnx
0
madmare
Asked:
madmare
  • 2
  • 2
1 Solution
 
b1xml2Commented:
then go explicit:
System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
0
 
madmareAuthor Commented:
i am adding more than one panel by this way, all these panels have the same name because i am adding by Button_Click event, the problem is by the MouseMove event on one of these panels, becuase i haven't add it in design time the compiler write to me that the namespace couldn't be found.
0
 
b1xml2Commented:
p.MouseMove += new MouseEventHandler(Form1.Panel_MouseMove);

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
  Panel p = (Panel)sender;                  
}
0
 
madmareAuthor Commented:
thnx alot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now