日期:2014-05-19  浏览次数:20907 次

为什么做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中的代码重构做的比较强大了些.