I have a windows application which works when the application is running, however in design view, the code in the OnLoad event crashes due to a host of reasons. Is there a way to do something like this:
private void WindowsForm_OnLoad(object sender, EventArgs e)
{
if (IsDesignView())
{
// some code that breaks in design view but works normally
}
There is the DesignMode property inheritied from Component.
Though there is a better way to do it than that, since if I recall correctly, sometimes there can be issues with the
DesignModeproperty. I think I have some code somewhere, let me find it.EDIT: Well, I can’t find what I was thinking of, but this answer discusses some of the downsides of
DesignModeyou should keep in mind, as well as a workaround for a specific issue. However, the issue doesn’t affect what you want to do here, it doesn’t look like, but it’s good to be aware of it anyway.