Microsoft Developer Network > 포럼 홈 > .NET Base Class Library > How could I determine am I in design-time or run-time in my code when using Inheritance
질문하기질문하기
 

답변됨How could I determine am I in design-time or run-time in my code when using Inheritance

  • 2009년 11월 4일 수요일 오후 9:15A.Aziem Moemen 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    I have 2 Windows Forms named (FrmBase, FrmRegularForm)

    FrmRegularForm inherits FrmBase

    FrmBase contains FrmBase_Load event handler :
        MessageBox.Show("TEST");

    When I open  FrmRegularForm in design-time --> FrmBase_Load fires  and I believe that it's RIGHT

    Now, I want to preent this action @ design-time

    I NEED IT IN RUN-TIME ONLY

    Any suggestion is appreciated.

답변

  • 2009년 11월 4일 수요일 오후 10:19JaedenRuiner 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    All descendants of System.ComponentModel.Component (which includes System.Windows.Forms.Control, and thus subsequently System.Windows.Forms.Form) all contain a Protected property: DesignMode

    thus:

    public sub FrmBase_Load(sender as object, e as EventArgs) handles me.Load
      If Not MyBase.DesignMode then
          MesageBox.Show("Test")
      end if
    End Sub

    Cheers
    Jaeden "Sifo Dyas" al'Raec Ruiner

    "Never Trust a computer. Your brain is smarter than any micro-chip."

모든 응답

  • 2009년 11월 4일 수요일 오후 10:19JaedenRuiner 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    All descendants of System.ComponentModel.Component (which includes System.Windows.Forms.Control, and thus subsequently System.Windows.Forms.Form) all contain a Protected property: DesignMode

    thus:

    public sub FrmBase_Load(sender as object, e as EventArgs) handles me.Load
      If Not MyBase.DesignMode then
          MesageBox.Show("Test")
      end if
    End Sub

    Cheers
    Jaeden "Sifo Dyas" al'Raec Ruiner

    "Never Trust a computer. Your brain is smarter than any micro-chip."