Windows Develop Bookmark and Share   
 index > Windows Forms Designer > how to know that a user control is in design mode
 

how to know that a user control is in design mode

I have a user control which normally displays a large amount of data from an application.

This is similar to an excel chart.

When I drop this control onto a form, I want to put some dummy data in, so that properties can be previewed. I can't see how (within the control code) to determine that the control is in design mode.

How can this be determined?

Trev

Trevor2006  Tuesday, January 09, 2007 4:48 AM

Use the DesignMode property on the control (it's actually defined on Component, which Control inherits from). Sometimes that isn't always accurate, so it's sometimes a good idea to use it together with a check against System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime.

Sean Hederman  Tuesday, January 09, 2007 5:22 AM

Use the DesignMode property on the control (it's actually defined on Component, which Control inherits from). Sometimes that isn't always accurate, so it's sometimes a good idea to use it together with a check against System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime.

Sean Hederman  Tuesday, January 09, 2007 5:22 AM
Sean Hederman wrote:

Use the DesignMode property on the control (it's actually defined on Component, which Control inherits from). Sometimes that isn't always accurate...



Actually, it IS always accurate - in any method other than the constructor. Until the constructor exits, the object isn't fully 'sited' - that is, it isn't fully constructed and the DesignMode property doesn't have all the information it needs to return the correct value.

I know, that makes it kind of hard to make special design-time behavior, but there it is..
Patrick Sears  Wednesday, January 10, 2007 2:43 AM
Not in my experience. I've had issues with DesignMode in the OnHandleCreated override, although not for a while, so maybe that was a bug that was fixed.
Sean Hederman  Wednesday, January 10, 2007 4:34 AM

You can use google to search for other answers

Custom Search

More Threads

• UserControl as Container
• Custom Control, how to make custom EventArg?
• DataMember property not found
• Generics and Localization in Designer Generated Code
• Get the ExternaProvider Control Refrence in the UITypeEditor
• Scroll bar movement
• How to get key events in a controldesigner
• Smart Tag not generate Design time code .
• Resizing Panels with splitter control
• listBox or listView: 1 item=Multiple rows with formatting