Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to tell when a form is being designed?

Posted on 2007-10-17
Medium Priority
Last Modified: 2010-04-15
I've got code in my form load.

When I switch to design view, the design crashes with an exception. It looks like it is running my Load code - if I comment this out, I can see a design time view of my form.

In delphi, a form had a ComponentState property - this indicated, amongst other things if the form was being designed (you could omit certain code from executing if this was the case). Is there a C# equivalent - i.e. how can I stop the form designer from running my Load code - or at least limit which code it is trying to execute.


Question by:steve-west
  • 2
LVL 21

Accepted Solution

surajguptha earned 2000 total points
ID: 20094153
Here is a solution for your problem

Author Comment

ID: 20094350
Job done.

LVL 12

Expert Comment

ID: 20094378
DesignMode doesn't work in several cases - it depends on the parents all being set correctly. You'll find it's often 'wrong'...

So I'd use LicenseManager.UsageMode instead, which always seems to work..

Author Comment

ID: 20094393
Thanks for the info, andrewjb.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Screencast - Getting to Know the Pipeline
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question