如何让 Visual Studio 2008 Windows 窗体设计器呈现实现抽象基类的窗体? [英] How can I get Visual Studio 2008 Windows Forms designer to render a Form that implements an abstract base class?

查看:31
本文介绍了如何让 Visual Studio 2008 Windows 窗体设计器呈现实现抽象基类的窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了 Windows 窗体中继承控件的问题,需要一些建议.

I engaged a problem with inherited Controls in Windows Forms and need some advice on it.

我确实为列表中的项目(由面板制成的自制 GUI 列表)使用了一个基类,以及一些用于可以添加到列表中的每种类型的数据的继承控件.

I do use a base class for items in a List (selfmade GUI list made of a panel) and some inherited controls that are for each type of data that could be added to the list.

它没有问题,但我现在发现,使基控件成为抽象类是正确的,因为它有方法,需要在所有继承的控件中实现,从基类中的代码,但不能也不能在基类中实现.

There was no problem with it, but I now found out, that it would be right, to make the base-control an abstract class, since it has methods, that need to be implemented in all inherited controls, called from the code inside the base-control, but must not and can not be implemented in the base class.

当我将基本控件标记为抽象时,Visual Studio 2008 设计器拒绝加载窗口.

When I mark the base-control as abstract, the Visual Studio 2008 Designer refuses to load the window.

有没有办法让设计器使用抽象的基本控件?

Is there a way to get the Designer work with the base-control made abstract?

推荐答案

我知道必须有一种方法可以做到这一点(而且我找到了一种干净利落的方法).盛的解决方案正是我想出的临时解决方法,但在朋友指出 Form 类最终继承自 abstract 类之后,我们应该能够得到这样做了.如果他们能做到,我们也能做到.

I KNEW there had to be a way to do this (and I found a way to do this cleanly). Sheng's solution is exactly what I came up with as a temporary workaround but after a friend pointed out that the Form class eventually inherited from an abstract class, we SHOULD be able to get this done. If they can do it, we can do it.

我们从这段代码到问题

Form1 : Form

问题

public class Form1 : BaseForm
...
public abstract class BaseForm : Form

这就是最初的问题发挥作用的地方.前面说过,有朋友指出System.Windows.Forms.Form实现了一个抽象的基类.我们能够找到...

This is where the initial question came into play. As said before, a friend pointed out that System.Windows.Forms.Form implements a base class that is abstract. We were able to find...

  • 继承层次结构:

  • Inheritance Hierarchy:

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