c# - Shown handler in Form's base class in the way of designer -


i have base class inherits form, registers event handler on shown:

class baseclass : form {     public baseclass() : base() {         shown += new eventhandler(baseclass_shown);     }     void baseclass_shown(object sender, eventargs e) {         close();         messagebox.show("this cannot opened.");     } } 

now, when subclass form , open in designer, messsage , closes form in designer making impossible me visually edit it.

is there perhaps boolean can use prevent close() , messagebox happen?

(little background: close not called, depends on runtime settings , data)

some events fired in designer well, gives winforms designer wysiwyg ability. notably paint, shown fired, etcetera. designmode property provided allow tell whether event handler running @ design-time. fix:

void baseclass_shown(object sender, eventargs e) {     if (!this.designmode) {         close();         messagebox.show("this cannot opened.");     } } 

do note flaw in approach, event fires derived form. might helping much.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -