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.
  • 相关阅读:
    Request和Session的生命周期
    了解EBP指针
    esp跟ebp跟踪记录
    深入浅出Node.js (6)
    洛谷 P2404 自然数的拆分问题
    洛谷 P1852 奇怪的字符串
    洛谷 P1433 吃奶酪
    洛谷 P1881 绳子对折
    洛谷 P1162 填涂颜色
    P1145 约瑟夫
  • 原文地址:https://www.cnblogs.com/luqingfei/p/674617.html
Copyright © 2011-2022 走看看