Common forms and constructor VS

I have a base class

internal partial class View<T> : UserControl
  where T : class
{
    protected T t;
}

and I want to get the child from the view

internal partial class ViewChild<T> : View<T>
  where T : class
{
}

It works fine, but I cannot edit ViewChild in VS constructor. I know that the problem is the base base class. However, I do not understand how I can avoid this in this case. Is there any way to fix this?

+3
source share
2 answers

There is another way, and it does not rely on compiler flags:

http://wonkitect.wordpress.com/2008/06/20/using-visual-studio-whidbey-to-design-abstract-forms/

I would not recommend using conditional compilation. It is much better to work with the framework, and not against it.

, VS . TypeDescriptionProvider, VS .

, , , , s > 25 UserControls, .

+3

Generics , T. :

http://adamhouldsworth.blogspot.co.uk/2010/02/winforms-visual-inheritance-limitations.html

, "" :

  • BaseControl<T> : UserControl
  • CustomerControl_Design : BaseControl<Customer>
  • CustomerControl : CustomerControl_Design

DEBUG RELEASE:

#if DEBUG

namespace MyNamespace
{
    using System;


    public partial class CustomerEditorControl_Design : BaseEditorControl<Customer>
    {
        public CustomerEditorControl_Design()
            : base()
        {
            InitializeComponent();
        }
    }
}

#endif

    public partial class CustomerEditorControl
#if DEBUG
        : CustomerEditorControl_Design
#else
        : BaseEditorControl<Customer>
#endif
    {
    }

CustomerControl, , . .

, CustomerControl : BaseControl<Customer> , T, - , - .

Microsoft , .

+2

All Articles