Winform Custom Control: DesignMode doesn't 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.


It could be that the control must also must have an ISite associated with it, otherwise it will always return false

The design mode indicator is stored in the ISite; therefore, if the Component does not have an ISite associated with it, the value of this property is false.

Source: MSDN

Edit: Also see this post as someone had a similar problem to the one you're facing

Windows Forms designer and DesignMode property issues

Edit 2: I also found a site that seems to indicate that this is a common problem with custom controls but it also lists some work arounds. You can find it here:

Custom Control Design Mode Problem


For what I remember in the Ctor the DesignMode property has not its value yet. You should use it after initializeComponents or in an event handler.

Tags:

C#

Winforms