ControlDesigner

发布时间:2017-7-9 7:16:10编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"ControlDesigner ",主要涉及到ControlDesigner 方面的内容,对于ControlDesigner 感兴趣的同学可以参考一下。

GetHitTest

https://stackoverflow.com/questions/7762397/how-do-i-click-a-usercontrols-child-in-designer

@Bradley: thanks for pointing me in the right direction

You will need to write a ControlDesigner class, then use it in a [Designer( ... )] attribute on your UserControl.

See the example here: http://msdn.microsoft.com/en-us/library/sycctd1z(v=VS.90).aspx

For the actual click:

http://msdn.microsoft.com/en-us/library/system.windows.forms.design.controldesigner.gethittest(v=VS.90).aspx

The ControlDesigner has a protected bool GetHitTest(Point point) method - you can implement this in your ControlDesigner and return true when you want your control to handle a click, based on the click's location on the screen.

Example

 protected override bool GetHitTest(Point point)
        {
            bool flag = false;
            ASVerticalTab tab = Control as ASVerticalTab;
            if (tab != null)
            {
                Point clientPoint = tab.PointToClient(point);

                foreach (Control control in tab.TabPages)
                {
                    ASVerticalTabPage tabPage = control as ASVerticalTabPage;
                    if (tabPage == null)
                    {
                        continue;
                    }
                    var menuItem = tabPage.MenuItem;
                    var actualRectangle = new Rectangle(menuItem.Location, menuItem.Size);
                    if (actualRectangle.Contains(clientPoint))
                    {
                        flag = true;
                        break;
                    }
                }
            }
            return flag;
        }

关于DesignMode

https://stackoverflow.com/questions/4346361/winform-custom-control-designmode-doesnt-return-true-whereas-in-design-mode

LicenseManager.UsageMode is intended for this.

It is in fact the only reliable way to detect if your control is in design mode or not. It's only valid during the constructor, but it can easily be stored in a field of the class for later reference.

The DesignMode property for nested controls will be false even when the container control is in design mode.

在类的构造函数里面,使用一个字段存一下 LicenseManager.UsageMode

相关资料

http://www.cnblogs.com/blueglass/archive/2012/06/01/2530030.html

Extending Design-Time Support

Custom Designers


上一篇:Hive安装与配置——深入浅出学Hive
下一篇:内核调试日志打印宏

相关文章

关键词: ControlDesigner

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。