自定义控件的 Enum类和Color类 属性的公开设定
来源:互联网 发布:淘宝虚拟试衣功能在哪 编辑:程序博客网 时间:2024/05/01 10:59
我们知道 常规状态下
自定义控件经常使用String,Boolean型的属性
这些属性公开后 在使用时 就可以看到可输入的文本框
及有true和false供选择的下拉列表
可是我们有时还要用到 更多内容的下拉列表 或 颜色选择框
那么 下面就是
自定义控件的 Enum类和Color类 属性的公开设定 的示例
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace WebControlLibrary3
{
/// <summary>
/// WebCustomControl1 的摘要描述。
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
public class WebCustomControl1 : System.Web.UI.WebControls.WebControl
{
private string _text;
private Button _button;
private System.Drawing.Color _color;
[Bindable(true),
Category("Appearance"),
DefaultValue("default_text"),
Description("文本属性,显示在属性样下边提示部分")]
public string Text
{
get
{
return _text;
}
set
{
_text = value;
}
}
// 枚举
public enum TextStyle
{
Normal,
Italic,
Bold,
}
private TextStyle _textStyle;
public TextStyle textStyle
{
get
{
return _textStyle;
}
set
{
_textStyle = value;
}
}
// 系统颜色对话框
[Bindable(true),
Category("Appearance"),
DefaultValue("Red"),
Description("按钮背景颜色")]
public System.Drawing.Color ButtonColor
{
get
{
return _color;
}
set
{
_color = value;
}
}
/// <summary>
/// 呈现这个控制项到 output 参数所指定的物件。
/// </summary>
/// <param name="output"> 指定要输出的 HTML 写入器 (HTMLTextWriter)</param>
protected override void Render(HtmlTextWriter output)
{
string StartStyle = null;
string EndStyle = null;
switch(this._textStyle)
{
case TextStyle.Normal:
StartStyle="";
EndStyle="";
break;
case TextStyle.Italic:
StartStyle="<I>";
EndStyle="</I>";
break;
case TextStyle.Bold:
StartStyle="<B>";
EndStyle="</B>";
break;
}
output.Write(StartStyle+Text+EndStyle);
_button = new Button();
_button.Text = "测试Color按钮";
_button.BackColor = this._color;
_button.RenderControl(output);
}
}
}
- 自定义控件的 Enum类和Color类 属性的公开设定
- 自定义控件的 Enum类和Color类 属性的公开设定
- ActiveX控件的Color属性
- 自定义控件和自定义属性的总结
- 自定义控件和自定义属性的总结
- Enum类和enum关键字的区别
- 如何按照HashTable动态设定类的属性和字段
- 通过enum的名字设定enum对象
- 自定义控件(7)公开控件属性
- 自定义控件的属性
- 自定义控件的属性
- 控件的自定义属性
- 自定义控件的属性
- 自定义控件的自定义属性
- 自定义控件的自定义属性
- 自定义控件--自定义控件的属性
- Textfield的属性设定和键盘回收
- Flex中如何利用iconFunction属性在ComboBox控件的下拉菜单中设定自定义图标的例子
- SQL2000 和 SQL2005 下 行列转换 示例
- SQL 2005 Express 的“企业管理器” 下载
- VS2005 安装项目 需要学习
- [引用]SQL Server 2005 Books Online How to: Create a Job with Steps and a Schedule in Visual Basic .NET
- VS2005 通过SMO(SQL Management Objects) 管理 数据库的作业 警报 备份 等任务
- 自定义控件的 Enum类和Color类 属性的公开设定
- 正则表达式 验证 ****年**月
- VS2005 XML注释生成XML文档文件
- 浏览器兼容
- 得到内网可用的SqlServer 及某数据库下的表及其他的架构
- Duwamish示例下载
- 华表 单元格公式设定与计算
- 设置VS团队开发 统一的编码方式为:签名的UTF-8
- Tomcat Web.xml写法