如何说服visual studio designer显示派生抽象基类的控件 [英] How to persuade visual studio designer to show controls derived of abstract base class

查看:136
本文介绍了如何说服visual studio designer显示派生抽象基类的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正致力于改进现有项目(相当大),涉及屏幕管理(大约250个屏幕用于数据输入,设置和结果显示)。我决定创建一个抽象基类,强制派生的屏幕实现一些基本功能。



现在我遇到设计师拒绝显示受影响的屏幕的问题在我编辑之后(参见 A B C



为了向您展示我的问题,我创建了一个可以下载的测试程序这里

移动派生屏幕中的一个按钮并重新编译后,设计师拒绝显示用户界面,直到重新启动visual studio。



我很好奇是否可以在不使用#IF DEBUG或非抽象的中间类的情况下解决设计师的限制。



非常感谢提前,

Robert



我尝试了什么:



通过谷歌搜索我已经解决了设计器(Visual Studio 2012 Update 5)通常无法通过提供TypeDescriptionProvider显示从抽象基类派生的屏幕的基本问题。我找到了我在这里中描述的原则。

Currently I'm working on improvements of an existing project (it's quite big) concerning the administration of screens (about 250 screens for data input, setup and presentation of results). I decided to create a abstract base class which forces the derived screens to implement some basic functionality.

Now I suffer from the problem that the designer refuses to show the affected screens after I edited it in (see A, B and C.

To show you my problem I created a test-program which you can download here.
After you move one of the buttons in the derived screen and recompile, the designer refuses to show the user interface until you restart visual studio.

I'm curious if it's possible to work around the limitation of the designer without using #IF DEBUG or intermediate classes which aren't abstract.

Many thanks in advance,
Robert

What I have tried:

By googling I've already solved the basic problem that the designer (Visual Studio 2012 Update 5) normally can't show screens which are derived from an abstract base class by providing a TypeDescriptionProvider. I found the principle I use described in here.

推荐答案

这是我自VS2005以来一直抱怨的问题!

你不能直接显示任何基于派生类的控件,但是它周围有一个kludge:从摘要中衍生出一个具体的类UserControl [ ^ ]

这在任何方面都不理想,但它确实有效。
That's a problem I've been complaining about since VS2005!
You can't directly display any control that is based on a derived class, but there is a kludge round it: Deriving a concrete class from an abstract UserControl[^]
It's not ideal in any way, but it works.


这篇关于如何说服visual studio designer显示派生抽象基类的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆