zoukankan      html  css  js  c++  java
  • Dot Net WinForm 控件开发 (二) 给控件来点描述信息

          在这里用到 属性(Attribute),  属性(Attribute)与属性(Property)不同, 前者是用来描述编程元素的,后都是用来描述对象的. 简单地说, 错了不要骂我!!!

    将一篇代码稍稍改动了一点:
     1using System.ComponentModel;
     2using System.Windows.Forms;
     3using System.Drawing;
     4
     5namespace CustomControlSample
     6{
     7    public class FirstControl : Control
     8    {
     9        private int simpleField;
    10
    11        [Category("我是属性,我怕谁!")]
    12        [Description("我是属性,故我在(属性浏览器中)!")]
    13        public int SimpleProperty
    14        {
    15            get return simpleField; }
    16            set { simpleField = value; }
    17        }

    18
    19        protected override void OnPaint(PaintEventArgs e)
    20        {
    21            base.OnPaint(e);
    22            e.Graphics.DrawRectangle(Pens.Red, new Rectangle(Point.Empty, new Size(Width - 1, Height - 1)));
    23        }

    24    }

    25}



    The end.
  • 相关阅读:
    053-98
    053-672
    053-675
    1031 Hello World for U (20分)
    1065 A+B and C (64bit) (20分)
    1012 The Best Rank (25分)
    1015 Reversible Primes (20分)
    1013 Battle Over Cities (25分)
    1011 World Cup Betting (20分)
    1004 Counting Leaves (30分)
  • 原文地址:https://www.cnblogs.com/luqingfei/p/674617.html
Copyright © 2011-2022 走看看