读书人

为什么做WINFORM控件时用不了Category

发布时间: 2011-12-30 23:30:45 作者: rapoo

为什么做WINFORM控件时用不了Category??
控件的代码如下,编译时出错,说是找不到类型或命名空间:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace test1
{
class Class1:Control
{
[
Category( "Flash "),
Description( "The ending color of the bar. ")
]
private int x;


public int X
{
get { return x; }
set
{
x = value;
Invalidate();
}
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawLine(new System.Drawing.Pen(System.Drawing.Color.Blue), 1, 1, 100, 100);


}
private void InitializeComponent()
{
this.SuspendLayout();
this.ResumeLayout(false);
}



}
}

[解决办法]
如果在VS2005中,可以用编辑器自己的来加这个名称空间.
[解决办法]
比如当你写上Category后,且没有using System.ComponentModel这句话,编辑器会出现一个红的小空心下线,用鼠标点它就可以让系统自动的来把using加上.
[解决办法]
呵呵,既然解决了,我就只接分了
[解决办法]
如果是VS2003的话,这个动作就要由手动来添加了,VS2005中的代码重构做的比较强大了些.

读书人网 >C#

热点推荐