从控件的构造函数中检测设计模式 [英] Detecting design mode from a Control's constructor

查看:16
本文介绍了从控件的构造函数中检测设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

后续来自 这个问题,是否可以从对象的构造函数中检测一个对象是处于设计模式还是运行时模式?

Following-on from this question, is it possible to detect whether one is in design or runtime mode from within an object's constructor?

我意识到这可能是不可能的,我必须改变我想要的,但现在我对这个具体问题感兴趣.

I realise that this may not be possible, and that I'll have to change what I want, but for now I'm interested in this specific question.

推荐答案

您可以使用 System.ComponentModel 命名空间中的 rel="noreferrer">LicenceUsageMode 枚举:

You can use the LicenceUsageMode enumeration in the System.ComponentModel namespace:

bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);

这篇关于从控件的构造函数中检测设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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