Вопрос, связанный с дизайном поверхности Паоло Фоти
Can anyone help me answering to my question that how can we implement the click events for dynamically generated component inside Designer. I had referred <a href="https://www.codeproject.com/Articles/60175/The-DesignSurface-Extended-Class-is-Back-Together">The DesignSurface (Extended) Class is Back, Together with a DesignSurfaceManager (Extended) Class and a Form Designer Demo!</a>[<a href="https://www.codeproject.com/Articles/60175/The-DesignSurface-Extended-Class-is-Back-Together" target="_blank" title="New Window">^</a>] website
Что я уже пробовал:
I have use below snippet inside class MenuCommandServiceExt:IMenuCommandService class but didn't got any success. if ((string)menuItem.Tag == "Label") { var lbl1 = (Label)surface.CreateControl(typeof(Label), new Size(300, 20), new Point(10, 80)); this.lbl1.Text = "Hello World by DesignSurfaceExt"; this.lbl1.Click += new EventHandler(btnclick_Click); this.lbl1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lbl_MouseDoubleClick); } I also tried to achieve it through creating a user control for Label with all the events defined inside the label and creating it through above code snippet but it also didn't worked. Below is the logic I used for user control. if ((string)menuItem.Tag == "Label") { var lbl1 = (MyLabel)surface.CreateControl(typeof(MyLabel), new Size(300, 20), new Point(10, 80)); } User Control public class MyLabel : Label { public MyLabel() { this.DoubleClick += new EventHandler(MyLabel_Click); } void MyLabel_Click(object sender, EventArgs e) { MessageBox.Show("Clicked"); } ......... ..... ... } Also, I want to save/view my custom form which I built inside the Powerful DesignSurface Designer. How can I achieve that?