惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Martin Fowler
Martin Fowler
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
IT之家
IT之家
云风的 BLOG
云风的 BLOG
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
P
Proofpoint News Feed
博客园_首页
J
Java Code Geeks
C
Check Point Blog
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
D
Docker
U
Unit 42
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
GbyAI
GbyAI
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog

博客园 - 左佩玉

通过了 70-316 考试 .NET SDK 工具 线程 进程 程序配置 程序集 全局化和本地化 实现帮助 可访问性设计 访问和调用外部组件 实现打印 使用 GDI+ 在ADO.net 中使用xml 绑定、查看和筛选数据 ADO.net 处理和抛出异常 使用Debug和Trace 测试和调试 继承 System.Collections.CollectionBase 创建一个强类型集合类
自定义控件
左佩玉 · 2005-08-24 · via 博客园 - 左佩玉

不让控件的public属性显示在属性窗口,public属性自动显示
[System.ComponentModel.Browsable(false)]
public int StockNumber
{
    //.....
}

继承控件
public class myButton:System.Windows.Forms.Button
{
    //....
}

添加新功能,例
protected override void OnKeyPress(KeyPressEventArgs e)
{
    if (char.IsNumber(e.KeyChar) == false)
   {
        e.Handled = true;
   }
}

改变外观 
protected override void OnPaint(PaintEventArgs pe)
{
   System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath();
   myPath.AddString("Wow",Font.FontFamily,(int)Font.Style,72,new PointF(0,0),StringFormat.GenericDefault);
   Region myRegion = new Region(myPath);
   this.Region = myRegion;
}

UserControl设计器
  组合一个或多个控件

OnPaint事件 PaintEventArgs参数有属性:Graphics    ClipRectangle
重新绘制控件,ClipRectangle仅表示需要重新绘制的区域

要使控件在每次调整大小时都重新绘制,标志:
SetStyle(ControlStyles.ResizeRedraw,true);

重绘控件 Refresh()