.net自定义控件(二)
来源:互联网 发布:淘宝处方药药师问什么 编辑:程序博客网 时间:2024/06/03 03:58
派生法
说明:以系统的某个控件为父类,派生一个新控件。
例如:以Button类作为父类,设计一个自定义控件MyButton(可以设置提示文本的按钮)
步骤:
1,在项目中添加“自定义控件”,类名MyButton,父类为Button;
2,为控件编程,添加自定义属性等;
3,为控件编程,添加方法(Public);
4,注意,此控件在设计视图窗口不可见;
调试:
1,保存,重新生成项目;
2,在工具栏中,能看到当前项目自定义的组件,其中包括自定义控件MyButton;
3,拖动到窗口;
有关代码:
public partial class MyButton : Button
{
private ToolTip _toolTip; //内置ToolTip控件
private string _TipsString;
[DefaultValue(null)]
[Description("提示消息"), Category("杂项")]
[Browsable(true)] //在属性窗口可见
public string TipsText
{
get { return this._TipsString; }
set
{
this._TipsString = value;
_toolTip.SetToolTip(this, _TipsString);
}
}
public MyButton()
{
InitializeComponent();
_toolTip = new ToolTip();
this._toolTip.InitialDelay = 0;
this._toolTip.ReshowDelay = 0;
this._toolTip.SetToolTip(this, _TipsString);
}
public void SetTip(string tips)
{
if (tips != null)
{
this._TipsString = tips;
this._toolTip.SetToolTip(this, _TipsString);
}
}
}
- .net自定义控件(二)
- 自定义asp.net控件分析(二)
- .NET 自定义Button控件(二)
- ASP.NET自定义控件开发示例(二)
- 自定义控件(二)
- 自定义控件(二)
- ASP.NET自定义控件组件开发(二)
- .net学习二:页面和自定义控件
- 开发asp.net自定义控件(asp.net学习笔记二)
- 自定义控件入门(二)
- 自定义控件View(二)
- Android 自定义控件(二)
- android 自定义控件(二)
- android 自定义控件(二)
- Android自定义控件(二)
- .net自定义控件(一)
- .net自定义控件(三)
- Android自定义控件(二)组合控件
- Lucas Kanade 光流法(来自wiki 百科)
- Ubuntu下Openfire的安装
- 巩固一下基础,java多项式相加
- .net自定义控件(一)
- 解决opensips启动时报ERROR:uri:db_checks_fixup1: configuration error 错误
- .net自定义控件(二)
- 倒置函数reverse
- 解决opensips启动时出现PID file /var/run/opensips.pid does not exist 的错误
- c++实现二叉搜索树
- 我的网站终于上线了
- Flash ANE打包
- .net自定义控件(三)
- sort函数降序排序
- nutch-1.4在eclipse中运行