c# - Assign MouseHover event to newly created Control -


this new control add code part:

        (int = 0; < 1; i++)         {             var newlabel = new label();             newlabel.location = new point(x, y);             newlabel.size = new system.drawing.size(25, 25);              newlabel.name = "lbl" + realpocsed.tostring();              if (value2== "value2")             {                 newlabel.mousemove += new mouseeventhandler(this.mycontrol_mousemove);                 newlabel.mousedown += new mouseeventhandler(this.mycontrol_mousedown);             }             if (value== "value1")             {                 newlabel.mousedown += new mouseeventhandler(this.mycontrol_mousehover);              }              panel1.controls.add(newlabel); 

the mousehover event this:

        private void mycontrol_mousehover(object sender, mouseeventargs e)     {         tooltip tooltip1 = new tooltip();         tooltip1.showalways = true;         tooltip1.show("t", x); // x should name of newly created label     } 

may ask if there way assign newly created name "lbl" + realpocsed.tostring() instead of x?

thank time.

inside for:

newlabel.mousehover += delegate (object sender, eventargs e) {     tooltip tooltip1 = new tooltip();     tooltip1.showalways = true;     tooltip1.show("t", newlabel); }; 

update:

if (value == "value1") {     newlabel.mousehover += delegate (object sender, eventargs e)     {         tooltip tooltip1 = new tooltip();         tooltip1.showalways = true;         tooltip1.show("t", newlabel);     }; } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -