Abstratct UserControl Class Prevents WinForm Design View

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gyanendar
    New Member
    • Jun 2007
    • 90

    Abstratct UserControl Class Prevents WinForm Design View

    Hi ,
    I have multi level of UserControls.Sa y FORM1 is main form ,then UserControl1.
    UserControl2:Us erControl1 &
    UserControl3:Us erControl2

    In UserContro2, there are some threading function which need to be overritten in UserControl3.So UserControl2 has been made abstract and that method too.
    Now Application is running fine but ,I am not able to view the designer of UserControl3.Th e error message i m getting "[B]The designer must create an instance of type 'TestWinForm.Us erControlLevel2 ' but it cannot because the type is declared as abstract. [/B]".
    Because of this error I am not able to modify the Layout of UserControl3.

    Please help .

    Regards,
    Gyanendar
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Have you tried changing from abstract to something else...
    Do your design work...
    Then change it back?

    Comment

    • gyanendar
      New Member
      • Jun 2007
      • 90

      #3
      Thanks for the reply.
      There are many functionality from abstract UserControl is reimplemented(b y overide) in other UserControl.So changing the abstract is not possible as it will throw many errors & warnings.

      Regards,
      Gyanendar

      Comment

      • ThatThatGuy
        Recognized Expert Contributor
        • Jul 2009
        • 453

        #4
        why even do you even want a user control to be abstract....
        If you want to build greater functionalities from an exisiting control then i suppose there's no need for you to declare that control as abstract...

        And rember OO concepts an abstract class can never be instantiated ...
        That may be the reason you're getting this error

        Comment

        • gyanendar
          New Member
          • Jun 2007
          • 90

          #5
          Yes as per OOPS concepts Abstract class can't be instantiated.
          But without making it abstract,how we can override the function in another userControl ?

          Comment

          • ThatThatGuy
            Recognized Expert Contributor
            • Jul 2009
            • 453

            #6
            Instead of abstract you can try virtual keyword....

            like this...
            Code:
            protected virtual void doSomething()
            {
            //////
            }
            this will enable the baseclasses to override doSomething() method....

            You previosuly made the usercontrol class as abstract because you wanted the methods to be abstract...
            because an abstract class cannot be instantiated the IDE is not able to create an instance of your user control.... SIMPLE

            Comment

            • gyanendar
              New Member
              • Jun 2007
              • 90

              #7
              yes, this will work.
              Thanks

              Comment

              Working...