| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
-
- using System.ComponentModel;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Dongke.WinForm.Controls
- {
- /// <summary>
- /// 标准标签控件
- /// </summary>
- [ToolboxBitmap(typeof(Label))]
- public class LblLabel : Label, IDKControl, IMustInput
- {
- #region 成员变量
- /// <summary>
- /// 控件是否是必须输入项目
- /// </summary>
- private bool _mustInput = false;
- private bool _showMustInputAlert = true;
- #endregion
- #region 构造函数
- /// <summary>
- /// 标准标签控件
- /// </summary>
- public LblLabel()
- {
- this.BackColor = Color.Transparent;
- this.AutoSize = true;
- }
- #endregion
- #region 属性
- /// <summary>
- /// 获取或设置控件是否是必须输入项目
- /// </summary>
- [DefaultValue(false)]
- [Description("获取或设置控件是否是必须输入项目。"), Category("CustomerEx")]
- public bool MustInput
- {
- get
- {
- return this._mustInput;
- }
- set
- {
- if (this._mustInput != value)
- {
- this._mustInput = value;
- this.Invalidate();
- }
- }
- }
- #endregion
- #region 重写属性
- /// <summary>
- /// 获取或设置控件的前景色
- /// </summary>
- public override Color ForeColor
- {
- get
- {
- if (this._mustInput)
- {
- return Constant.LABEL_FORECOLOR_MUSTINPUT;
- }
- return base.ForeColor;
- }
- //set
- //{
- // //if (!this._mustInput)
- // //{
- // // base.ForeColor = value;
- // //}
- //}
- }
- /// <summary>
- /// 获取或设置一个值,该值指示是否自动调整控件的大小以完整显示其内容
- /// </summary>
- [DefaultValue(true)]
- public override bool AutoSize
- {
- get
- {
- return base.AutoSize;
- }
- set
- {
- base.AutoSize = value;
- }
- }
- /// <summary>
- /// 获取或设置控件的背景色
- /// </summary>
- [DefaultValue(typeof(Color), "Transparent")]
- public override Color BackColor
- {
- get
- {
- return base.BackColor;
- }
- set
- {
- base.BackColor = value;
- }
- }
- /// <summary>
- /// 获取或设置控件是否显示必须输入项目提示
- /// </summary>
- [Description("获取或设置控件是否显示必须输入项目提示。"), Category("CustomerEx")]
- [DefaultValue(true)]
- [Bindable(false)]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool ShowMustInputAlert
- {
- get
- {
- return this._showMustInputAlert;
- }
- set
- {
- if (this._showMustInputAlert != value)
- {
- this._showMustInputAlert = value;
- }
- }
- }
- /// <summary>
- /// 清除输入项
- /// </summary>
- public virtual void ClearValue()
- {
- this.Text = string.Empty;
- }
- #endregion
- }
- }
|