与paolo foti有关的设计表面问题 [英] Question related to design surface by paolo foti

查看:67
本文介绍了与paolo foti有关的设计表面问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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  





我尝试过的事情:





What I have tried:

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?

推荐答案

不要在快速答案下发布 - 如果您从文章中获得了代码,那么是该文章底部的添加评论或问题按钮,这会将电子邮件发送给作者。然后他们会被告知你希望与他们交谈。

在这里发布这个依赖于他们匆匆而过并意识到这是为了他们。
Don't post this under Quick Answers - if you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.


这篇关于与paolo foti有关的设计表面问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆