DesignMode checking can be troublesome with form inheritance. An example would be a base form has an OnLoad that does something
private void OnLoad(object sender, EventArgs e)
{
if (!DesignMode)
{
//Do something here.
}
}
Where the trouble starts is when the derived form is loaded in the visual studio designer. DesignMode solving to true in the base form is not always guaranteed, therefore an acceptable solution would be the following:
///
/// Indicates if the current view is being utilized in the VS.NET IDE or not.
///
public new bool DesignMode
{
get
{
return (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv");
}
}
4 comments:
great tip!
really helped me a lot....
It agree, it is the amusing answer
I do not know.
Nice tip , check further to automate winform development at http://razaimran.blogspot.com/
Post a Comment