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

making event to panel that added in running time

 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
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

  • 2
  • 2
1 Solution
then go explicit:
System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
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.
p.MouseMove += new MouseEventHandler(Form1.Panel_MouseMove);

private void Form1_MouseMove(object sender, MouseEventArgs e)
  Panel p = (Panel)sender;                  
madmareAuthor Commented:
thnx alot
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