【发布时间】:2011-04-19 21:35:59
【问题描述】:
以下代码是一个自定义控件。在 Visual Studio 设计器中使用此控件会导致 Visual Studio 在没有任何明显细节的情况下崩溃。
我正在使用 Visual Studio 2008。
我在这里做错了吗?
using System;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace InstalacionesSayma.GUI
{
public class CustomControlTest : Panel
{
private Label _label;
public CustomControlTest()
{
_label = new Label();
this.Controls.Add(_label);
}
public override Font Font
{
get
{
return _label.Font;
}
set
{
_label.Font = value;
}
}
}
}
【问题讨论】:
-
我不确定,但我会从构造函数中删除
this.Controls.Add(_label);并将其放在其他位置 - 如果您有 *.Design.cs,请在此处进行设置...跨度>
标签: c# .net winforms crash custom-controls